Pages

Tuesday, November 30, 2010

Learning Python Coding Techniques and Idioms by Browsing Python Source Code


Study the standard libraries source code for good examples of Python coding.


Using Pythonic Idioms and Style:
Definition of "Pythonic" here
Presentations:
How to Write Pythonic" code by Christopher Arndt
Presentation on "Code Like a Pythonista: Idiomatic Python" by David Goodger
Presentation on "Code Like a Pythonista: Idiomatic Python" (Crunchy Remix) by Jeff Hinrich 

Bruce Eckel's community contributed book: Python 3 - Patterns & Idioms


See Also:
My blog on Learning Python

Source Code Browsing Tools

Source Insight 3.5 Download Instructions
Source Insight Video 
ack -- better than grep, a power search tool for programmers
Source-Navigator
Splint Home Page (C code static checking)
Browse by Query
scan.coverity.com : Accelerating Open Source Quality  

Eclipse:
Eclipse IDE with C++ CDT
Eclipse CDT 4.0 Webinar
This webinar will walk through all of CDT's features from new project creation, code editing, and source navigation, to build and debug with a special focus on what's new in CDT 4.0.  
Eclipse CDT - Webinar on Developing C/C++ Applications
Eclipse C++ Development Howtos, Tutorials, Guides and Videos

NetBeans:
NetBeans IDE with C++ support
NetBeans - Development with C and C++ Learning Trail

Global

GNU GLOBAL source code tag system
idutils - Summary [Savannah]
taglist.vim - Source code browser (supports C-C++, java, perl, python, tcl, sql, php, etc) vim
Using Global with Vim Tutorial

CScope

cbrowser | Get cbrowser at SourceForge.net
VI and VIM editor: Tutorial and advanced features from YoLinux
Vim-Cscope tutorial

Ctags

Browsing programs with tags - Vim Tips Wiki - a Wikia wiki
Exuberant Ctags
Exuberant Ctags FAQ
VI and VIM editor: Tutorial and advanced features

Doxygen

___CodeProject: 10 Minutes to document your code. Free source code and programming help
__Download details HTML Help Workshop and Documentation
__Graphviz Setup Download
Doxygen (Extensions to doxygen for other languages support)
Doxygen Commenting Commands
Doxygen Projects
Doxygen Quick Reference.pdf (application/pdf Object)
Eclox (plugin integrates Doxygen with Eclipse)
Graphviz
graphviz build notes
MscGen - Wikipedia, the free encyclopedia
Mscgen A Message Sequence Chart Renderer (Call Sequence)
xchm (chm for Unix Linux MacOSx)
chmProcessor: Word/HTML to CHM converter
Doxygen Browser Addin for Visual Studio
Download Doxygen Browser 0.1.3 Beta Free - Softpedia

GCC_XML

__Boost.Python (the C++ Python connection)
__Boost.Python C++ code generator Introduction
__Edison Design Group (C++ Compiler Based Analysis for Tools)
__pyplusplus introduction
__Pyste (Boost C++ code generator) Documentation
__Python C++ language binding
__What is Boost.Python Tutorial
FAQ ___GCC-XML (cpp2xml) - Generate XML description of C++ code
Info on Parsing C++ at nobugs.org - UnUpdated but Useful
pygccxml - Python parser for GCC-XML output
pyste - Boost.Python wrapper generator for GCC-XML
Sourceforge - C++ Python Language Bindings Download
The gccxml Mailing List Archives
The VFiasco Project (with Links on Parsing C++)

Lxr

___SourceForge.net LXR Cross Referencer
__LXR - The Linux Cross Reference (like SourceInsight)

Vim

0scan - Tags based search for any things you might want to find(ctags, buffers etc)
C++ code completion - Vim Tips Wiki
OmniCppComplete - C/C++ omni-completion with ctags database : vim online
Recommended Vim plugins for C coding? - Stack Overflow
SourceCodeObedience - Browse source code easily with cscope, ctags and marks system

Learning by Source Code Browsing Miniaturized Open Source Software

Links:

[Networking]
Tiny Http daemon: thttpd (tiny http web server), apache's httpd at trunk - GitHub
Pion : (Web Analytics Server written in C++ Boost under Boost Open Source license)
Pion binary downloads for Redhat, Ubuntu, OSX and Windows are available at: http://www.atomiclabs.com/pion-web-analytics/download.php
1) Pion Core Platform: Pion Core is an open source software platform for building stream computing (also known as complex event processing) applications.
2) Pion-Net Library:The Pion Network Library (pion-net) is a C++ development library for implementing lightweight HTTP interfaces. (C++ Boost STL Multithreading Asio Networking Library) Download the source code here


ACE:

  • ACE is an open-source framework that provides many components and patterns for developing high-performance, distributed real-time and embedded systems. ACE provides powerful, yet efficient abstractions for sockets, demultiplexing loops, threads, synchronization primitives.

  • TAO (The ACE ORB) is an open-source implementation of a CORBA Object Request Broker (ORB) built using components and patterns in the ACE framework.

  • CIAO (Component Integrated ACE ORB) is an open-source implementation of the CORBA Component Model (CCM) built on top of TAO.

  • DAnCE is an open-source implementation of the Deployment and Configuration standard (D&C) built on top of TAO.



  • Download ACE, TAO and CIAO source code  (Distributed Network Middleware Framework and ORB)

    uIP (Micro implementation of TCP/IP stack)
    Download - uIP source
    Memcached distribute caching: memcached - Google Code, memcached - GitHub



    [STL]
    SGI STL Site and Resources (Design docs, FAQs, Books)
    Download SGI STL source code (C++ Standard Template Library implementation)
    (Related to STL)
    A standard allocator for C++ STL on sourceforge
    Database Template Library - DTL on sourceforge
    DTL docs
    Download DTL source code

    [Other]
    VideoLAN - VLC media player source code
    LXR Cross Referencer  (Online Source code Browser)

    TODO: Resources for Source Code Reading

    (Podcast) Software Engineering Radio on Software Archaeology
    (Audio) Grady Booch on Software Archaeology and Related Topics (OOPSLA)
    (Book) Code Reading : The Open Source Perspective
    (Book) Working Effectively with Legacy Code by Michael Feathers
    (Book) The Visual Display of Quantitative Information by Edward R. Tufte
    (Tool/Article) GLIMPSE :  A tool to search through entire filesystems
    60 Years of Software Archaelogy
    An Empirical Approach to Software Archaeology
    (Book/SW) Software Tools in Pascal by Kernighan and Plauger
    (Paper) Locating Program Features using Execution Slices
    (Paper) Programmers use Slices when Debugging by Mark Weiser
    (Article) OOD Archaeology with CIA++
    (Paper) On the criteria to be used for decomposing systems into modules by Parnas
    (Paper) Porting Unix to WindowsNT
    (Article/Paper) Seeking the Source
    Software Archaeology: Reconstructing the Evolution of Software
    Software Maintainance as Part of the SDLC
    (Paper) The relationship between slices and module cohesion
    Usenix-Interix

    Tuesday, October 19, 2010

    Source Code Reading Check-List Part 1

    Code Reading check-list giving tips-n-tricks:

    1. Search the source code repository for expert coders i.e. by author name. Reading high-quality code helps to develop good coding habits.
    2. Power browsing. Keep track of the goals before you start browsing code. Note them down and keep referring to them. This will help ensure you stick to the goals you started out with.
    3. All systems are simple. The most complex software is written quite simply. It needs to be dumbed down to the level of a computer. Get over your awe of a complex system. There is no magic involved.
    4. Backtrack from the first appearance of a bug to its actual origin.
    5. Get Debugging information using the following methods:
      • Debugger
      • Compiler warning/intermediate code
      • strace - trace of calls to operating system functions like open(), read() etc.
      • Logs created by the database, library, or application.
      • Network monitoring tools - wireshark,
      • Windows message capture
    6. To add features or extend existing source code, try to find the closest matching existing code. Simply copy-paste code and settings followed by customizing it will suffice. Note: The greater the similarity of features between your code and existing code the less work you have to put in the customization.
    7. Create a KeyWord-List by examining the source for the following patterns:
      • String messages,
      • Log statements,
      • Menu Items,
      • Function names,
      • Macros,
      • Other search terms - (You'll need to adapt the search terms as per coding style)
      • Example: getXYZ(), setXYZ(), updateXYZ(), selectXYZ(), addXYZ(), updateXYZ(), deleteXYZ() etc which point to behaviour control mechanisms.
    8. Keep adding to the KeyWord-List as you get more familiar with the source code conventions and style. This list will be most useful for future reference by you or a team member.
    9. Pay close attention to compiler warnings and error messages. You can reduce days of work by easily finding to areas of mismatch (without even having to read code) Esp. useful while porting and modifying existing source.
    10. Add unit-tests for regression checking the source code. This allows you to refactor code confidently without worrying about causing more bugs than you fix. Any tests that fail will point immediately to the source and scope of the bug.
    11. Esp. when working with obfuscated code, sometimes writing your own code is easier than trying to understand, refactor and reuse someone else's code.
    12. There are a few basic approaches to source reading:
      • Bottom-up vs Top-Down i.e. implementation layer vs. managing layer,
      • Easy modules vs. Complex modules or Easy code vs Complex code,
      • Unit Tests vs Source code - Usage versus Implementation
      • Given a choice try to take the easy way out for the time being.
      • You can always come back later to difficult parts with more insight from your earlier efforts.
    13. Search for nuggets of information in the following places:
      • file and directory organization - (names of files/folders are suggestive of usage),
      • makefiles/project files - (project dependencies often a source of versioning bugs)
      • settings mechanism - files, cmd-line options, environment variables, hard-coded values, keywords used in source code.
      • UI mechanism - (understand the functionality by executing test code)
      • Documentation - specs, design, readmes, forums, bug reports, user guide, marketing docs, presentations.
    See Also:
    Code Reading : The Open Source Perspective by Diomidis Spinellis