Some basic programming tips Oct25 '06
Before any coding begins, it's important to step back and view the larger picture.
Ask yourself:
"Do we really need to add this feature? Is there something that already exists that can complete the same task, resulting in less man-hours?"
As a developer, I am always hesitant when adding anything. I hate adding things. Therefore, before I add anything, I always look for existing ways to achieve the same result.
Not only does this approach reduce the amount of excess code - it eases maintenance, later on down the road.
Restrict adding. Always re-use.
An application is only as good as you know it.
This quote simply means that, as a developer, you should be aware of every "nook and cranny" of your applications. Every "corner of your code" should hold meaning to you.
Once a set of code loses it's meaning, it becomes a task to restore that meaning.
This is evident every time you have to fix code that you haven't touched in a while, and may not be heavily commented.
Not only is there a million different ways to do something, you don't always have to take the most "obvious" approach.
It's important to hold suggestions (from others) under a spotlight. Never jump into a suggestion from someone else, until it has been thoroughly analyzed and re-analyzed.
There's no use in quickly adding code that simply "works." Yes, the tools available allow for almost anything, but this could result in excess code - and more importantly, without fully examining the existing code, you may even be adding duplicate code.
Consider duplicate code as your worst enemy.
Imagine if every task that you did each day - wake up, brush your teeth, pump gas in your car, drive to work - imagine if you had to do everything twice. Everything - every day.
And if you didn't do it twice, it never actually happens.
I can imagine you'd lose your sanity rather fast.
This is what modifying duplicate code feels like, for a developer. Every time a small thing needs to be changed, it has to be changed in multiple spots. And it's very easy to forget that multiple spots exist, until someone is yelling in your ear about a page error.
Therefore, never... never... never repeat the same code twice.
Categories: Programming
, Web Development ![]()
Add Feedback (view all)
Leave feedback
Hmm I always heard the term as "refactor". ... Read more.
Yeah, I hear "factor out common code" and "refactor the code." Eclipse IDE has a "Refactor" menu, I believe other IDEs call it this too. I would s ... Read more.
I've never used either term, so I'm gonna trust you both on this one... :) ... Read more.
matthom
is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago.
Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.
Similar Entries
- Cell phone tips, or tricks? (96 recent visits)
- Bluetooth headset tips and ideas (660 recent visits)
- Amazon wishlist tips (257 recent visits)
- Car buying tips (4 recent visits)
- Best practices for programming and web development (4 recent visits)
- PHP OO programming references? (7 recent visits)
Stats
6 unique visits since October 2008
Recent Referrers (click)
- http://matthom.com/archive/200
- http://matthom.com/archive/200
- http://matthom.com/archive/200
- always
- http://matthom.com/archive/200
- http://matthom.com/archive/200
- http://matthom.com/archive/200
- http://matthom.com/archive/200
- always
- http://matthom.com/archive/200
- http://matthom.com/archive/200
- http://matthom.com/archive/200
- http://matthom.com/archive/200
- always
- http://matthom.com/archive/200
When duplicate code exists, you want to "factor" this out into an interface or helper class so that you have a single point of failure and a single ... Read more.