Best way to teach yourself programming?

Good programming practice suggestions

  • Inside, I've posted a question about computer programming, regarding organizing class libraries and packages -- and also regarding good programming practices. I've been programming in Actionscript (Flash's programming language) for a few years. Now, Macromedia has released Actionscript 2.0, which, for the first time, allows you to set up class libraries (and packages). I've never programmed before in a language with this feature, and I'm looking for tips about library structure. In other words, what is a good way to organize folders and subfolders (i.e. a graphics folder, a math folder, etc.) for classes. Once you set up a structure, it's hard to modify it in the future, so I want to get off to a good start. Also, I know there are great books about good programming practices (comment your code, use descriptive variable names, etc.), but can anyone recommend a website with a succinct list of tips about code structure, clarity and organization? If there isn't a site (though I'm sure there must be), maybe people could share their favorite tips here. In addition to my own programming, I also teach Flash to designers. My classes involve some Actionscript, and I'd like to get my students off to a good start. Most of them won't read a book, but if I can give them some power-tips, they will use them and write code that's at least passable.

  • Answer:

    IMO, the best book in the world with regard to good programming practice is "Code Complete" by Steve McConnell. You'll find this from any number of sources. (Side Note: Version 2 of this book is coming out soon - See http://www.stevemcconnell.com/cc2/cc.htm%20 for more info.) His Class chapter can also be found http://www.stevemcconnell.com/cc2/06-Classes.pdf

grumblebee at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

I'll second seanyboy's recommendation; McConnell's book is great, and everyone who's serious about writing good code should re-read their copy every couple of years. I don't know anything about Actionscript or Flash, but in C++ I try to organize each module around one primary class. The module usually contains other classes which support the main class, but the main class is generally the only one other parts of the program interact with. Sometimes these support classes grow up and turn into important structures in their own right, in which case I break them off into new modules of their own. For example, a year or two ago I wrote a debugger. It started out as one module, centered around the debugger window itself. The primary class was the DebuggerWindow, but the file also contained a StackViewList control, a VariablesList control, a SourceViewPane, and so on. Eventually we added an ObjectViewer window, which got its own sub-module under the Debugger section. This window also called the VariablesList, so we moved the VariablesList out into its own sub-module too. Now there's a "Debugger" directory containing the main debugger module, the ScopeViewList module, the ObjectViewerWindow module, and so on. I guess my advice is not to stress about it too much up front. Keep each folder you create focused on one concept; if it gets too large, break it down into subfolders. Let the structure arise out of the implementation instead of deciding what the structure should be up front and fitting your code into it. This is kind of a refactoring-oriented style, but I've found it works and leaves you with project structures that may not look as pretty as you'd like, but actually *work* nonetheless.

Mars Saxman

+1 for Code Complete. Great book regardless of your language of choice.

trillion

For designing things in an object oriented environment, I have to recommend http://www.amazon.com/exec/obidos/tg/detail/-/0201633612/102-9926333-4184937?v=glance. Good software always comes back to good design.

chrisroberts

If you want to quickly learn what OO programming you might as well learn a very clean OO language at the same time. I'd say pick up _Programming Ruby: A Pragmatic Programmer's Guide_ and go through it. Learn OO principles and Ruby and when you come out the other side you will know how to think about your issues. OO programming is something that you will benefit from diving into and really obsessing about for a few weeks. Just dipping your toe into it makes it seem complex.... the OO way of doing things is actually much simpler in that it is very well organized.

n9

If you want to quickly learn what OO programming you might as well learn a very clean OO language at the same time. I'd disagree with this. I really got the feel for OO programming while learning to do it in C from Roger Sessions http://www.accu.org/bookreviews/public/reviews/c/c000281.htm. Yes, you really can do OO development in plain ol' C... and learning this way taught me not only to be very grateful for language features that make it easier but also to impose the discipline of OO (and other good) design tactics on myself. But grumblebee, your question doesn't have an easy answer. Learning elegant design comes only with experience -- trying and refining your own ideas, and diving into other peoples. Looking for books on design patterns is probably worthwhile, though.

weston

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.