Difference between revisions of "Programing Tips"

From OpenCircuits
Jump to navigation Jump to search
m (1 revision)
Line 37: Line 37:
 
= Good Coding is Good =
 
= Good Coding is Good =
  
 +
Writing bad code in a hurry will often bite you.  Write good code as much of the time as you can.  May well be faster in the long run.
  
 +
= More =
 +
 +
* [[Intermediate Programing Tips]]
 +
* [[Russ Python Tips and Techniques]]
 +
* Use Google Python Tips and Techniques
 +
 +
 
[[Category:Python]] [[Category:Draft]]
 
[[Category:Python]] [[Category:Draft]]

Revision as of 16:42, 17 February 2017

These are my personal tips for programming, they work for me, not sure all programmers will endorse. Some of these tips overlap with each other, hope this is not confusing.

Copy Work Is Good

This is key, if you can copy code instead of writing it you can save a whole lot of work. There is nothing wrong with this given that you understand the code that you copy. I copy mostly from myself, I actually keep little pieces of code around to copy from or go into my collection of past projects. This may also give you code that works sooner. If not from yourself then use google. This is not like getting homework from another person in the class ( unless that is what you are actually doing ). The point is to get good code working and be able to do it again in the future.

Start Small and Expand

You will typically break a complicated task down into steps. It is a good idea to program and test each individually and then put the pieces together. Each time through the code should get bigger ( functionally ) and better. Some components, like error management, I sometimes leave until the basic code is running. There is a whole philosophy of system development where successive improvement of code is a chore idea.

Put Working Components Together

This is part of the idea of Start Small and Expand, see above.

Learn More Python

From time to time make an effort to learn. Pick up a Python book, read a blog, actually read the documentation. Python is big and getting to some of the advanced topics can take a long time. Any time your coding seems tedious, stop and question your approach. Learn a bit more and the task may not be so tedious.

Test

Test your code. Writing special sections of code just for test is a great idea. Learn about the whole concept of unit testing. Google "Python Unit Testing"

Keep Track Of Your Own Code

Since you want to copy from your own code, and build on old projects, keep your code organized.

Google Is Your Friend

Got a Python problem. I can almost always find an answer on Google ( or Bing..... ). Usually the process it quick. Use It.

Get Used to Writing Good Comments

There is a lot to say about good comments. I will only say a small amount here.

  • Comments should tell the intent or purpose of the code. Do not tell what the code does, your reader ( usually you ) can read the code.
  • Comments form the internal documentation of the code. There are some Python standards. I should put a link here......
  • Comments sometimes warn about something unusual in the code.
  • Comments are a good place to keep track of enhancements that might be made in the code.

Use Libraries

If you are trying to do something big and complicated, something that is not too far off the beaten track, someone may have written a library for it. Want a web server, there are a bunch of libraries for it. Images, yep there is stuff out there. Look before you code up a storm.

Good Coding is Good

Writing bad code in a hurry will often bite you. Write good code as much of the time as you can. May well be faster in the long run.

More