Download - How to be a Guru Coder
1/23www.teratech.com
How to become a Guru Coder
Michael Smith
TeraTech, [email protected]
http://www.teratech.com
301-424-3903 x110
Copyright TeraTech
2/23www.teratech.com
What is a Guru Coder?
3/23www.teratech.com
Overview
• A guru coder…Writes great programs that users love to
useCode is easy to maintainWorks well in teamsHas few bugsIs good at solving problems in a simple
way
• Guru coder: born or learned?
4/23www.teratech.com
Speaker Information
Who am I?
• Michael Smith
• President of TeraTech, Inc
• MDCFUG, CFUnited, Fusebox Conf
• Articles in CFDJ, Fusion Authority
• Winner CFDJ award Best Consulting
5/23www.teratech.com
Programming Experience
• 30+ years programming
• 15+ years with ColdFusion
• Also work with SQL, JavaScript, HTML, VB, Oracle, Access
• Teach one-on-one and custom classes
• custom development
• Fusebox and Process Methodology
6/23www.teratech.com
Does character matter?
• Studies show that 85% of a programmers success is due to human factors rather than pure technical skills.
7/23www.teratech.com
What human factors does a Guru Coder Have?
8/23www.teratech.com
Guru Coder Character
• Humble
• Curious
• Honest
• Communication
• Coding conventions
• Lazy
• Thinking and Planning
9/23www.teratech.com
Not as important
• Persistence – pigheaded
• Experience – is 10 years of experience or 10 x 1 year’s experience?
• Jolt programming – all nightersCode disappear can be good – chance to
rewrite
Tweaking forever for perfect code
10/23www.teratech.com
Humble
• My brain can’t take in the whole program at once - use coding crutches
• Egoless programming, Rewrite complex code• Code reviews• Ask for help if stuck > 15 minutes• Murphy’s law• Examples in comments• Reference Change Tracker issue# and Desc• Document algorithm used
11/23www.teratech.com
Reduce complexity
• Avoid global data• Short routines, few parameters• Limited nesting• Data driven vs complex logic• Named constants – rather than magic
numbers• Descriptive names – variable,
database, files, short, no weird characters
12/23www.teratech.com
Modularize to simplify
• Hide details – black box
• De-Couple routines
• Cohesion – do one thing well
• Test parameters as they come into each module
13/23www.teratech.com
Curious
• How can I improve?• Constantly learning• Experiment• Problem solving and planning skills• Case studies - Programming Pearls,
alphablox.com, open source sourceforge.net• RTFM and magazines, websites• Likes challenging projects• Google skills
14/23www.teratech.com
Honesty
• I don’t know
• I was wrong
• Fix bugs rather than covering up
• Understand code before you run it
• True status reports – including “bad” news
• Stand by accurate estimates
15/23www.teratech.com
Communication skills
• WORM code, not WMRO code (spaghetti)• Write code for humans to read, not for
computer to run• Clear emails • Use the phone, F2F meetings
correct understandingGet extra information
• EQ. Listen to upsets, allow let off steam• Remember the user – actors, photo,
useability testing
16/23www.teratech.com
Code for humans to read
• WORM code is easier to:UnderstandReviewLess errorsFaster to debugEasier to modifyFaster to develop overall
• Sets a good habit for team
17/23www.teratech.com
Coding conventions
• Save having to think about that part of code
• Variable and database naming
• Indenting clarifies meaning
• InCONsistent Case confuses
• Avoid poor constructs
• Bad spelling propagates
• Scope variables, avoid public
http://www.cfug-md.org/articles.cfm#code
18/23www.teratech.com
Lazy
• Write smart code instead of repetition of code• Write or use a tool instead of repeating steps
by hand• Macros in your code editor• Use a pre-built tool vs reinventing the wheel• Write less code – copy existing code,
searchable library of code• Use a template/ existing document• Consistent look between programmers and
projects
19/23www.teratech.com
Planning
Plan before you Code before you Debug
Think before you Document before you Code before you Run
Test as you go
20/23www.teratech.com
More good habits
• Code and understand before running• End loops before coding the “filling”• Don’t go long with code “broken”• Plan before coding• Figure out how you will test code before
coding• Take a break; sleep on problems• “Telephone” review of problem to a buddy• Write algorithm on whiteboard – diagram
21/23www.teratech.com
Good Commenting
• Comment to relate distant open and close tags
• Comment – “see below” rather than break up code
• Don’t make code or comments go off the page horizontally - printable
22/23www.teratech.com
Defensive coding
• If it can go wrong it will go wrong
• Check parameters exist and data type
• Throw errors if assumptions not met
• Always code the ELSE part of IF
23/23www.teratech.com
Debugging• If you can prove your algorithm must work
It is less effort than to Debug.
• Test Parameters at and beyond their limits.(Some tests must show a failure)
• Keep it Simple, Stupid (Kiss)If you can’t remember and/or understand what it
does, how can it be maintained?
• Use debug mode variable to get extra info, stop page execution, save to file, email to self
• Take a break, take different approach• Use multiple catches
24/23www.teratech.com
Resources
• “Code Complete”
by Steve McConnell
• “The Mythical Man-Month”
by Frederick Brooks
• “Peopleware”
by Tom Demarco, et al