Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

The title express my intention. I want to see the code of a big project that can be considered a good example of good code writing (clean code, modularization, comments, etc.)

I don't want to know if the tool is good or not, but only how the code IS.

There is some project that can be used as example?

I'm asking this because must great projects have their flaws, some pieces or entire code that appears to be writing to a new person presented to system development (I think that maybe everyone do this in some part of their projects).

share|improve this question
2  
I've heard that the clang project's code is very clean, although I can't confirm that. – FUZxxl Nov 24 '11 at 19:26
2  
What language(s) you are interested in? – Péter Török Nov 24 '11 at 21:58
1  
@PéterTörök The language is not specific. I think a good code will legible even for somebody don't know that language, but if is possible, Java, that is the language I'm using at the moment, but I really don't care about the language. – Renato Dinhani Conceição Nov 25 '11 at 1:10
2  
3  
@RenatoDinhaniConceição, this may be a false assumption, unless you are familiar with an unusually wide range of languages based on different paradigms (OO, procedural, functional, protoype-based, ...). – Péter Török Nov 25 '11 at 8:12
show 1 more comment

closed as not constructive by Mark Trapp Jan 11 '12 at 3:35

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.

5 Answers

The greatest example of clean code in the PHP world is Zend Framework. Some stats, derived from its ohloh page:

  • Lines of code ~ 3.5*10^6
  • Comments ~ 0.7*10^6
  • Contributors: 234

ZF is extremely well documented, there's a reference guide, generated api documentation, a contributor oriented wiki and an issue tracker. Almost all code is covered by unit tests and there are clearly defined coding and testing standards. The overall documentation efforts are quite impressive, and you should be able to dive into the code soon.

Although the codebase is fairly big and with quite a few commiters, if you take the time to browse the code you'll see it's extremely consistent and clean.


You should also really check out Code Review Stack Exchange. It's not what you are looking for per se, but you'll find more than few great discussions on clean code on specific pieces of code.

share|improve this answer
These standards are great and appears to be a good guideline for any kind of projects. – Renato Dinhani Conceição Nov 25 '11 at 1:17
We've built our coding standards on top of ZF's and several known PHP projects are converting theirs to be closer to ZF's. Far from becoming the definitive standard for the wider community, but definitely a very important document in a community that's extremely chaotic when it comes to standards. – Yannis Rizos Nov 25 '11 at 1:23
-1 : something you forgot to mention : 8 instances of global keyword in ZF2.0 source .. – teresko Nov 29 '11 at 2:23
2  
@teresko 8 instances of global in a 3.5*10^6 loc project? I only hope you are as vigilant in your own projects... Would you care to provide an example of a cleaner PHP project of equal (or slightly less) size? – Yannis Rizos Nov 29 '11 at 2:26
I did not even mention the rest of global state , introduced by use of static classes , singletons and registries. ZF is horrible even when compared to other php frameworks (which, honestly, is kinda an achievement in itself). It is NOT a project from which one should learn good practices. – teresko Nov 29 '11 at 2:40
show 2 more comments

I find Qt and Chromium to seem quite clean to me.

share|improve this answer
6  
I hope you're kidding about Qt. No exception safety, use of an external tool (moc) to preprocess C++ code, overuse of macros, etc. I'm sure that these design decisions made sense almost two decades ago, but they don't now. – In silico Nov 25 '11 at 0:38
1  
Actually the Qt project discourages macros. Can you provide a basis for your claim about macro overuse? The exception safety in C++ is a controversial topic at best (for example Google's C++ guidlines advise against using them IIRC). I don't see what moc has to do with code cleanness. Sure, it's not really C++ but that wasn't a requirement of OP either. – fish Nov 25 '11 at 1:05
1  
@Tamás Szelei: For a project that discourages macros, it sure uses lots of them (for example, signals/slots). And Google's C++ guidelines are the way they are because they have lots of legacy systems they need to support; they are of course not indicative of modern practice. Again, Qt's design would've made perfect sense 19 years ago, but they don't today. The OP's requirements do not include C++, but if you're going to look at C++ code, you might as well look at proper modern C++ code. – In silico Nov 25 '11 at 21:25
Signals and slots are not really macros, that's why moc is in place. What legacy systems does Google support? I respect your opinion that Qt is not proper, modern C++ code, but you don't really provide anything to support it, just keep repeating it. I read lots of the Qt source and I do think it's clean and well-written. – fish Nov 25 '11 at 21:29
@In silico: care to give an example of modern C++ code? And please don't say boost! – Violet Giraffe Nov 25 '11 at 22:02
show 2 more comments

Notepad2 seemed nice the last time I checked it. You'll also need Scintilla to build it. Also, useful if you're interested in modifying an editor for your needs.

share|improve this answer

Webkit seems like a high quality open source project.

I can't do any C++ myself personally, but I can follow and read the webkit source when I want to understand browser internals.

And there is git aswell.

share|improve this answer

Tcl (sourceforge) has a reputation for being very well written code.

share|improve this answer
Why the downvote? Even if you don't think the language itself is useful, the code itself is still very well written. – Bryan Oakley May 19 at 3:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.