TeraTech

The ColdFusion Experts: Develop | Secure | Optimize

  • Services
  • About
  • CF Alive
  • Blog
  • Podcast
  • Contact

  • Services
  • About
  • CF Alive
  • Blog
  • Podcast
  • Contact

Does your ColdFusion Code Smell Bad? (16 certified checks)

October 5, 2016 By Michaela Light Leave a Comment

I am not talking about literal bad smell from your computer! I mean is there something “off” about it. Not a bug, but poor design or architecture weakness that will make maintenance a bear?

blond man bad smell sign

Holding you nose when maintaining your code?

Defn: Code smell is any symptom in your source code that may indicate a deeper problem in your system. Just like if you open your fridge door and the smell is bad that is a sign that some of your food is rotting.

“[Code] smells are certain structures in the code that indicate violation of fundamental design principles and negatively impact design quality” – Martin Fowler, author of the book “Refactoring.”

Code smells are (usually) not bugs — they are not broken code and don’t stop the program from run correctly. They are weaknesses in design that may slow down maintenance. Or may up your risk of future bugs and system failures.  Bad code smell is a sign that you have serious technical debt!

What to do? Start refactoring in small steps to eliminate obvious bad smells; checking that the code still functions correctly at each stage. This will often uncover other worse smells deeper in the design.

Think of it like updating an old house – you rip off some bad drywall only to uncover decrepit electrical wiring underneath.

For example, You might start refactoring out duplicate code only to discover that the database design is bad too.

Code smells indicate when to refactor, and what to do to fix it.

Where bad code smells come from

Some surprising results in an IEEE software study of 500,000 code commits in 200 open source software projects found that:

  • The majority of bad smells start at project creation, not during maintenance.
  • Although regular maintenance is responsible for most bad smells added after creation, poor refactoring can add them too.
  • Not all bad smells come from newbies on the code. Long time developers who are overworked and stressed are more likely to make new bad smells in code.

 

What do to have better smelling maintenance? Increased code review when the project is stressed!

 

The code smell zoo

zoo-24931_960_720

Application-level smells:

  • Duplicate code in different places.
  • Contrived complexity: using over-complicated design patterns where simpler design would get the job done well.

 

Class-level smells:

  • Hard coding of constants
    • Instead use named constants to both improve readability and to avoid programming errors in future maintenance. Put the constants in a CFinclude file so they are easy to find and change.
  • Orphan variable or constant class: a class that typically has a collection of constants that should be owned by another member classes.
  • Large class: it is too big to read or fix easily. A “God object”.
  • Feature envy: it uses the methods of another class too much.
  • Inappropriate intimacy: it depends on the internal coding of another class.
  • Refused bequest: it overrides a method of a base class but does not honor the original contract.
  • Lazy class/freeloader: it does too little!
  • Cyclomatic complexity: too many branches or loops. Break it up into smaller functions or write it in a simpler way.
  • Downcasting: a type cast which breaks the abstraction model → refactor/eliminate the abstraction.

 

Method-level smells:

  • Too many f*cking parameters: a long list of parameters is hard to read, and makes calling and testing the function complicated. Refactor so that responsibility is assigned in a more clean-cut way.
  • Long method: a method, function, or procedure that has grown too large.
  • Identifiers too long: eg using naming conventions to provide disambiguation rather making that clear in the software architecture.
  • Identifiers too short: the name of a variable should reflect its function. Except if it is obvious.
  • Too much return data: a function or method that returns more data than is needed to call it from all places it is used.

 

Action

Have your lead developer pick a “smell of the week” Then ask all developers to look for it during their regular work this week. They may fix the issue themselves or bring it back to you. As you go through the above smell list will gradually teach your team to be better developers.

 

PS What was the ‘worst' smell in your ColdFusion code last year? Leave a comment bellow.

Related Posts

  • State of the ColdFusion Union 2017 Survey Amazing ResultsState of the ColdFusion Union 2017 Survey Amazing Results
  • State of the ColdFusion Union 2017 Survey Amazing ResultsState of the ColdFusion Union 2017 Survey Amazing Results
  • 019 A Whirlwind Tour of Preside Application Framework in the Wild, with Alex Skinner
  • 017 Managing an international team, Git, CFML, Node, Joomla, Headaches and Heartaches, with Scott Coldwell017 Managing an international team, Git, CFML, Node, Joomla, Headaches and Heartaches, with Scott Coldwell
  • 011 Portable CFML with Cloud deployments, Microservices and REST with Jon Clausen011 Portable CFML with Cloud deployments, Microservices and REST with Jon Clausen
  • 010 All things ContentBox (new API, ContentStore, Themes and more) with Gavin Pickin010 All things ContentBox (new API, ContentStore, Themes and more) with Gavin Pickin
  • Facebook
  • Twitter
  • LinkedIn

Filed Under: ColdFusion, Development Approach, Management Tagged With: ColdFusion, ColdFusion code, Development Approach

← Previous Post State of the CF Union Survey 2016 (More Amazing Results)
Next Post → First 3 things to ask when hiring your next CFML developer

Popular podcast episodes

  • Revealing ColdFusion 2021 – Rakshith Naresh
  • CF and Angular – Nolan Erck
  • Migrating legacy CFML – Nolan Erck
  • Adobe API manager – Brian Sappey
  • Improve your CFML code – Kai Koenig

CF Alive Best Practices Checklist

 

Modern ColdFusion development best practices that reduce stress, inefficiency, project lifecycle costs while simultaneously increasing project velocity and innovation.

Top articles

  • CF Hosting (independent guide)
  • What is Adobe ColdFusion
  • Is Lucee CFML now better than ACF?
  • Is CF dead?
  • Learn CF (comprehensive list of resources)

Recent Posts

  • Funny ColdFusion Custom Tag Competition (CFML Programmer’s Jokes)
  • Protected: State of the CF Union 2021 Survey Results
  • ColdFusion Development: Less Coding for Faster Turnaround
  • Protected: State of the CF Union 2021 Survey Released
  • ColdFusion Server Crashing – First 3 Steps to Fix it Fast

Categories

  • ActionScript
  • Adobe CF Summit
  • Adobe CF Summit East
  • Adobe CF Summit East 2018
  • Adobe ColdFusion 11
  • Adobe ColdFusion 2020 Beta
  • Adobe ColdFusion 2021
  • Adobe ColdFusion Project Stratus
  • Adobe ColdFusion Security
  • AIR
  • Ajax
  • AngularJS
  • Announcement
  • API
  • Apollo
  • Auto Security Lockdown
  • AWS
  • C#
  • Certification
  • CF Alive
  • CF Alive Book
  • CF Alive Podcast
  • CF Camp
  • CF Developer week
  • CF Maintenance
  • CF Summit India
  • CF Tags
  • CF Training
  • CF Vs. Other Languages
  • CFEclipse
  • CFML
  • CFML Open- Source
  • CFObjective
  • cfquery
  • CFSummit
  • CFUnited
  • China Chopper
  • CIO
  • Classes
  • Client Highlights
  • ColdBox
  • ColdFusion
  • ColdFusion 2018
  • ColdFusion 2020
  • ColdFusion 2021
  • ColdFusion 9
  • ColdFusion community
  • ColdFusion Conference
  • ColdFusion Consulting
  • ColdFusion Developer
  • ColdFusion Development
  • ColdFusion Hosting
  • ColdFusion Roadmap
  • ColdFusion Security
  • ColdFusion Webinar
  • CommandBox
  • Conference
  • Cool Stuff
  • Culture
  • Cybercrime
  • Database
  • Development Approach
  • DevOps
  • Docker
  • Fixinator
  • Flex
  • Frameworks
  • Fusebox
  • FusionReactor
  • Futurology
  • Garbage Collector
  • Google Down
  • Into The Box Latam
  • IntoTheBox Conference
  • Java
  • JavaScript
  • JVM
  • Learn CFML
  • Learn ColdFusion
  • Legacy Code
  • Load Testing
  • Lucee
  • Management
  • MAX
  • MDCFUG Lunch
  • Microsoft Azure
  • Mindmapping
  • MockBox
  • Modernize ColdFusion
  • Monitoring
  • Muracon
  • NCDevCon
  • New Intern
  • News
  • Node.js
  • Open- Source
  • ORM
  • Ortus Developer Week
  • Ortus Roadshow
  • Performance
  • Performance Tuning
  • PHP
  • Productivity
  • Programming Languages
  • Project planning
  • Query of Queries
  • Scalability
  • Security
  • Server Crash
  • Server Software
  • Server Tuning
  • Social Media
  • Spiral Web
  • SQL
  • Success Story
  • Survey
  • Technology
  • TestBox
  • Tips
  • Transcript
  • Trapeze Development
  • Uncategorized
  • Web 2.0
  • Web Application
  • Web Server
  • Webinar
  • Webmail
  • What is ColdFusion?
  • Whole Brain Development
  • Women in Tech
  • Work From Home
  • Home
  • Services
  • About Us
  • CF Alive
    • CF Alive Book
    • CF Alive Inner Circle
    • CF Alive full resources cheatsheet
  • Blog
  • Podcast
    • Podcast Guest schedule
  • Contact
  • Sitemap

The ColdFusion Experts:
Develop, Secure, Optimize

TeraTech Inc
451 Hungerford Drive Suite 119
Rockville, MD 20850

Tel : +1 (301) 424 3903
Fax: +1 (301) 762 8185

Follow us on Facebook Follow us on LinkedIn Follow us on Twitter Follow us on Pinterest Follow us on YouTube

Copyright © 1998–2021 TeraTech Inc. All rights Reserved.