Is looking at random code snippets useful to quickly determine the quality of a project?

To get an idea of the quality of a project that I’ve never seen before (usually open source projects that I’m considering whether or not to use), I often start by opening random files and eyeballing fine details of the code.

I look for things like:

  • Style (does it follow accepted conventions for the language and is it consistent)
  • Quality and consistency of comments
  • Common language specific gotchas (e.g. consistently not using === in javascript)
  • Does it look logically structured

I find this gives me a good idea of the skill of the developer/s that wrote the code, even if I know absolutely nothing about what the code is meant to be doing.

Do people think this is useful? What does one need to take into account for quickly assessing the quality of a project’s code base, assuming no knowledge of how it actually works?

3

How easy would it be for me to fix a bug in this code?

Whenever I encounter a new code base I ask myself that question.

Quickly familiarising myself with the code enables me to identify common ground with the developer(s) who created it. I tend to look for the following (in no particular order):

  • consistent use of naming conventions
  • an aversion to making code complex – adhering to the KISS principle
  • unit tests that work out of the box
  • a short readme file that describes the project with helpful hints to understanding
  • good comments
  • use of design patterns where appropriate
  • consistent style in comments and code layout
  • use of well-known and respected supporting libraries (e.g. Boost, Guava etc)
  • presence of language idioms

The more of the above are present then the more confidence I have in the skills and experience of the developers so that when the inevitable WTF?! moment occurs I am much more inclined to look to myself for a lack of understanding of the problem domain than assume that the original developer has made an error.

1

If you make only one pick, you’re likely doing it wrong. 🙂 Other than that this is essentially a random sampling, a pretty respectable approach to gather information in cases like you describe. For more scientific details on how this could be done, study about Monte Carlo method.

Regarding things to look for, consider finding, studying and tailoring to your specific needs some tried and true code-review checklist.


Some other aspects worth considering when evaluating a project are listed below (check list summarized from my past experience):

  • Releases (along with changelog), versioning and publishing discipline
    It’s generally much easier to investigate issues when one can tell bug was found in release 1.2.3, avaiable for download at some URL than oh two years ago someone sent me a mail with attached binary.

  • Developer documentation, API reference and code examples
    Helps to avoid efforts wasted on reinventing the wheel and learning basics by trial and error.
    Note these can be also randomly sampled for a quick study.

  • Bug tracking
    If there’s no tracking at all, it’s a huge red flag; if there’s one, consider quickly checking it using the same random sampling approach as you do for source code

  • Positive feedback
    Find out about project users and try to do a random sampling study of their feedback.

I think this method rather reveals styling skills and the ability of making code readable, but it tells nothing about logical, analytical, problem-solving skills of the developer(s) working on the code.

So when you analyse code this way, you gain information only about how “good” the code looks and whether it is readable or not. But still you have no idea if the code is optimized, if it works well, if it well structured, etc.

The characteristics you pay attention on are very important. They show if the code is readable and maintainable. But there are many programmers who give excellent solutions but don’t really pay attention to comments and styling (which I thinks is much easier to learn than programming itself).

Yes, I think that it’s a good idea. Projects which are poorly written is more likely to get abandoned.

But don’t base your decision just on that. imho source code history and number of committers are a far more important factor.

I think looking at small sections of code is a great way – if it is coded well, variables/classes/methods are named well and it is commented well, then understanding what a small section does and what its purpose is should be easy. If you have great difficulty understanding a small block (like anything brace-to-brace), then it is probably not coded all that well.

unless the samples are many and large, there’s a very good chance you’ll not going to get a good cross section of the codebase. You could end up with either the few good pieces or the few bad apples quite easily.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật