Are There Tools That Help Organizing #Includes

Is there a good standard for organizing complex Python code systems?

If these are the areas that you feel your application makes logical sense to be broken up into, then start creating the modules and moving code around in whichever way makes sense to you.

There's no real right way to do it as it's subjective to each individual use case, but there are static code analysis tools that can be used to help raise the quality level of your code.

Tools that I've used frequently are pep8 (mostly for convention adherence) and pylint. pyflakes is also apparently another great one (I've been meaning to use it). I've found that after running through pep8 and pylint, the number of changes that I've made makes my code much easier to grok (I also learn about some things that I had been doing poorly before) and the result has always been higher quality code overall.

As an aside, I read the comment from @Omnikrys and disagree. Python, being the multi-paradigm language it is, obviously lends itself well to OOP if you choose to go down that path. However, I've found that once you really figure out how to use Python in all of its duck-typing glory and really embrace the "we're all consenting adults" philosophy, you can start writing some very high quality, not over-engineered solutions. Of course, this is highly arguable (I've had quite a few debates on this subject) and completely up to you.

Detecting superfluous #includes in C/C++?

It's not automatic, but doxygen will produce dependency diagrams for #included files. You will have to go through them visually, but they can be very useful for getting a picture of what is using what.

How do you organize your work?

If you're at all used to Emacs, you might LOVE org-mode. I was not an emacs user, so it was a pretty steep learning curve for me, but it was so worth it. I now have a super fast plain-text based system with

  • hierarchical folding
  • search
  • tagging
  • scheduling / clocking
  • RSS fetching
  • email capabilities
  • NEW iPhone addon

all with a simple(?) Emacs addon. Frickin' perfect for me (and I'm a confessing productivity porn addict).


Secret tip for free: Combine this with the auto-file-syncing Dropbox (2.25 GB cloud space for free) and you'll never want anything else ever again. Well maybe that's a little bit of an overstatement...


Also, check out this article which really helped me get off the ground with a system that works well. He combines GTD and orgmode.

How to organise Javascript functions within complex object

There are many approaches here and it depends on how exactly you interact with your code.

Some things to keep in mind:

1) If the code is unwieldy, a refactoring is probably overdue.

Consider breaking your class into smaller classes each dealing with different aspects of what the big class does. Split functionality in multiple namespaces if you use static functions rather than classes.

Consider splitting functionality over multiple files (one-class-per-file for example) and having a build process that combines and minifies your output.

2) Tools can help.

If you deal with large codebases it's probably a good idea to find an editor (or learn to use its functions better) that can help you deal with it. Your IDE will probably have some functionality to help you navigate the file structure better, like a file structure overview, or code regions, or objects view

3) Organize functions by what makes sense.

An alphabetic solution could make sense in some situations, but grouping by functionality is probably better. Putting exported methods all in one place is probably a good idea as well:

Namespace = function() {
var f1 = function() { };
var f2 = function() { }; // this is internal

// Exported methods
return {
f1 : f1
}
}();

4) Document your code.

While reading the code is invaluable in giving someone an in-depth understanding, code ducmentation is essential in having a first-glance understanding. It can also be useful to you during development because you don't have to remember all the quirks of your code.

5) Enforce a coding style that can help you.

Your coding style can help you find things in the code easier. If you always use the same spacing, put braces the same way, etc, finding a function definition can be as easy as Ctrl-f: myFunc:.



Related Topics



Leave a reply



Submit