DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Maintenance
  4. Copy. Paste. Code?

Copy. Paste. Code?

How do you feel about copy/pasted code? Author Bill Sourour argues that's been the name of the game for some time and it's all good... that is, so long as you fully understand the code—particularly how it fits into your application—and are prepared to work with it in the future.

Bill Sourour user avatar by
Bill Sourour
·
Aug. 07, 16 · Opinion
Like (11)
Save
Tweet
Share
6.16K Views

Join the DZone community and get the full member experience.

Join For Free
"What percentage of your work would you say can be achieved by Googling for solutions, or libraries, or just posting on Stack Overflow?"

I was asked that question on social media recently. Ever since starting Dev Mastery a couple of months ago, I get a lot of questions over email and through Twitter and I always do my best to provide helpful answers. I found the above question particularly interesting and I’d like to share my answer with you here.

My first instinct when I saw it was to go into a sort of old man rant…

"Back in my day, we had to actually know what we were doing, we couldn’t just Google the answer! Kids today!! Arggghhh!!"


Of course, this doesn’t make any sense. First off, “back in my day” there were only a handful of libraries and commands you needed to know to be considered a decent programmer. If you cared about getting better, you had a well stocked bookshelf. Plus, we had mailing lists and newsgroups to go to and ask for help whenever we got stuck. It took longer, and didn’t have any "upvoting" functionality, but in principle, it was the same idea.

Today, with the wealth of information out there and the incredible pace of change, it’s impossible to just know everything and never Google or ask a question online. The trick is to do it in a way that leads to progress and not in a way that leads to problems.

Ideally, finding a quick answer or code snippet solution is the beginning, not the end, of your quest. If you just search for and blindly copy/paste code, in the best case scenario you’ll never get any better at writing code or solving problems (solving problems, by the way, is what your job is really about—great coders solve problems for a living). In the worst case scenario, you are going to seriously shoot yourself in the foot.
 
Here’s the deal, the best code is code that works well consistently and is easy to change. To achieve that, you must understand how each part of your app works and how it fits together with every other part of your app. Trying to change, improve, or extend code you don’t understand is very difficult, but trying to debug code that you don’t understand is a special kind of flaming hell. That sense of relief you got when you managed to just copy & paste some code, make it work, and move on, will pale in comparison to the wrenching frustration of trying to figure out what’s broken later. Trust me, I learned this painful lesson myself long ago and I’ve watched many, many programmers learn it since. Not fun.

"the best code is code that works well consistently and is easy to change"

So, what should you do? If finding the code snippet is the beginning, what’s the end game? The end game, of course, is understanding. Look carefully at the answer and the code you found and ask yourself, "Do I get this?" If there is any word or concept that is brand new to you and that you are not sure of, research it until you feel like you’ve got it. Then, try using the concepts you just learned to solve a different, related problem or try changing the code and predicting how it will react. Does it work like you expect it to? Can you change things and re-apply the knowledge? Yes? Great, you’ve got it! Not only will this make you a much better programmer over time, this will save you so many problems you can’t even begin to imagine!

I’m on a mission to help as many developers as I can. You can help me by recommending and sharing this article so that more people see it. For more advice like this, I invite you to sign up for my weekly newsletter at devmastery.com.

Debug code

Published at DZone with permission of . See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Securing VMs, Hosts, Kubernetes, and Cloud Services
  • SAST: How Code Analysis Tools Look for Security Flaws
  • Why You Should Automate Code Reviews
  • Streamlining Your Workflow With the Jenkins HTTP Request Plugin: A Guide to Replacing CURL in Scripts

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: