21

There have been one or two requests for code reviews for plug-ins and themes on the site in the past few weeks. WordPress Answers gives us the unique ability to post code, submit reviews, and vote on the reviews/feedback that's the most useful. Think of it as crowd-sourcing user opinions on unpublished code.

So here's my proposal. In lieu of a separate website for code reviews, I suggest we allow and encourage code reviews on WordPress Answers. It's a great way for people to learn both about their own code and about what others in the community are working on. Even though a code review might be specific to a certain plug-in, the feedback they receive won't be. The easiest way for a community to develop a set of coding standards is for the community to share code and discuss those standards openly.

If a developer wants to have their code reviewed, for one reason or another, they should do the following:

  • Create a new question on WordPress Answers explaining what their plug-in is trying to accomplish.
  • Include the actual code for their plug-in in the answer. If the plug-in spans multiple files, place them in separate code blocks on the page so we can keep things separate.
  • Tag your question as code-review

A moderator should mark the question as community wiki in fairly short order as well.

This allows you to receive feedback from multiple WordPress experts over a fairly short period of time. Everyone has their own specialty - some of us are RegEx pros, others work intently with $wpdb, others focus on core and cutting-edge features like post formats. So the feedback you'll receive for any one plug-in will be somewhat diverse and will make all of us better developers.

How does everyone feel about this proposal?

4
  • 1
    Great idea! Nothing to add other that to pledge support!!!
    – MikeSchinkel Mod
    Commented Nov 16, 2010 at 17:50
  • Watch out for upvote bots! Also, did you mean question or answer when you said where programmers should put the code. Commented Feb 9, 2011 at 22:48
  • How did this question get resolved? I'd love to get some broad feedback for my plugin, but it's not code review as such (and so O/T for the Code Review site). The code itself is fine, but I'm interested in whether I've embraced WP conventions, accessed WP hooks in a long-winded way, etc. If it is permissible, is a link to an off-site repo sufficient, given that replicating a small repo here is redundant?
    – halfer
    Commented Jul 7, 2013 at 12:18
  • Aha, I didn't spot the link in the sidebar - regarded as o/t. I'll find another place :).
    – halfer
    Commented Jul 7, 2013 at 18:07

5 Answers 5

6

As much as I want code reviews, I don't think this site is the best format for it. Code reviews to me are either focused on some specific lines of code ("You use $i here but $j there - by intent or mistake?") or on a larger concept ("Why did you choose to solve it this or that way?"). They require discussion, back-and-forths, while the comment system here is intentionally limited.

I know all of us want to do and request code reviews, and we must do something with all that positive energy, but I suggest we try to find (or create) a dedicated system to handle this, since it is a completely different beast than the "best answer floats to the top" style of Stack Exchange.

Edit: I searched around for code review software, and started playing with Rietveld, an open source project created by Guido van Rossum (creator of Python) at Google. One can easily host it on the Google App Engine, and you can play with a live version there. I have uploaded a file to see how this would work, maybe you all should take a look an see if this is a good starting point?

4
  • Best code review floats to the top...?
    – MikeSchinkel Mod
    Commented Nov 19, 2010 at 8:14
  • this is a very good point. I really appreciate your well-thought feedback. The best code reviews that I have are personal with other devs. Be it next to each other in front of the computer or far away from any box out in the fresh air. It's possible to offer some review here on SE and it's always good to give feedback to code, but as you wrote, it's difficult to do so. SE is as plattform limited to some specific written form of communication and interaction.
    – hakre
    Commented Nov 20, 2010 at 3:30
  • @Mike: As EAMann said, it's more likely that four reviewers each look at it with their specific strengths. In that case none of the reviews are "better" than any other. One specific recommendation can be more important than another (security hole vs. minor UI issue), but that would require scoring reviews per item.
    – Jan Fabry
    Commented Nov 20, 2010 at 10:48
  • Sounds like a community wiki...?
    – MikeSchinkel Mod
    Commented Nov 20, 2010 at 23:25
4

I feel that it is out of site's scope... But getting code reviewed is something I desperately want at times and personally I am all for such questions.

Issues I see:

  1. Are higher powers of Stack Exchange network ok (or care, or whatever) about such?
  2. I am not sure posting code in question's body is best way, at least for plugins that are hundreds of lines long.
  3. What about code that is not plugin? Like small (note that small doesn't mean simple) snippets and such?
3
  • 2
    1. Only one way to find out for sure (and I don't mean ask them). Better to ask for forgiveness than permission, and all that. Seriously, if we do this, and it seems to be working well, I doubt our efforts will be squashed. 2. We could always use something like pastebin or the like for longer bits of code. 3. I don't see any problems with smaller chunks of code.
    – Travis Northcutt Mod
    Commented Nov 17, 2010 at 4:22
  • @tnorthcutt - "Better to ask for forgiveness than permission, and all that." - Definitely +1.
    – MikeSchinkel Mod
    Commented Nov 18, 2010 at 6:03
  • 1
    My interest is more in small chuncks of code than full plugins. Too hard to review pull plugins well, but 20 lines of code that do one thing, that's doable.
    – MikeSchinkel Mod
    Commented Nov 18, 2010 at 6:04
2

In case anyone's keeping track, there's now a separate Code Review StackExchange that might meet this need:

Code Review Beta

OR

https://codereview.stackexchange.com/

5
  • Indeed, and I am very curious to see how this will turn out. I have my doubts, but we'll see how it goes!
    – Jan Fabry
    Commented Jan 26, 2011 at 22:54
  • 2
    Hmm... WordPress code can be very specific to WordPress APIs. I am not sure people without hands-on WordPress experience will be much interested in reviewing such. Will need to hang around there and maybe post some things as test.
    – Rarst
    Commented Jan 27, 2011 at 7:02
  • Nice! We could double post; a stub here and code over there?
    – MikeSchinkel Mod
    Commented Jan 28, 2011 at 10:48
  • @Rarst: That could be said about any system, really. But a generic code review process helps establish best practices in coding not best practices in using the WP API. There's a great deal of specific support needed for any framework-specific code review.
    – EAMann Mod
    Commented Jan 28, 2011 at 15:43
  • @MikeSchinkel: As much as I don't like double-posting, I think that would be effective. It would particularly help avoid situations where non-WP PHP developers are giving feedback that's structurally sound but goes against the coding quality principles used with WP.
    – EAMann Mod
    Commented Jan 28, 2011 at 15:44
1

What I like about code reviews is that it allows for others to see different ways that wordpress is being utilized/modified which in turn becomes a resource in itself.

I do believe they should be setup as wikis though.

1

I just saw a tweet by Joel Spolsky announcing a code review Stack Exchange site:

Step 1: Paste code you wrote into http://codereview.stackexchange.com. Step 2: Get feedback. Step 3: Apply for job as lion-tamer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .