SlideShare uma empresa Scribd logo
1 de 3
10 Good Programming Habits



Takeaway: Book learning will take you only so far. In the trenches, you need to develop sensible,
effective habits like these.

You learn lots of things when you go to college and get a computer science degree or read a how-
to-program book. Unfortunately, a number of good programming habits are either untaught or take
a good amount of practice to turn into a way of life. Here are 10 such habits you should cultivate
to become a better programmer.

1: Learn your source control process
You know that thing users like to do, where they pick up your application for the first time and get
angry because it doesn’t do things exactly the way they want — and then they refuse to learn how
the program works? You’re left scratching your head wondering why they didn’t bother to learn
the application, which would have saved them all sorts of problems.
Well, a lot of developers do that too, when it comes to working with source control. Every source
control system is a bit different and has a workflow that maximizes the value you get from it.
Learn that workflow! It may take some time, research, and practice, but trying to fight it by
making your source control repository look like the ugly mess you are used to creating on your
local hard drive defeats the purpose. You might as well just have good backups for your local
system and call it a day.

2: Go with obvious variable naming
This one comes up all the time: developers just give variables uninformative names and think it
doesn’t matter. Well, it does matter any time someone else comes in to look at the code. I can’t
speak for all developers, but I have yet to meet one who is typing for eight hours a day straight.
Adding a few keystrokes for better variable names (especially when modern IDEs will autofill it
for you) will make a measurable different in productivity. Stop making excuses and use better
variable names.

3: Use interfaces, not classes when possible
I violate this one all the time, and I know it. Whenever possible, code to an interface instead of a
class. For example, if your class needs to return an enumeration of Integers, there’s no need to
return a List<int>; return an IEnumerable<int>. This allows recipients to do what they want
without needing to recast or transform the results into a class that meets their needs.

4: Assume the worst from your peers
I’d love to think that everyone I worked with was as good, if not better than me at writing
software. In some jobs, it was usually true; but in others, it wasn’t. I did learn, though, that you
have to write your code as if someone with six months of experience (or someone with lots of
experience who just is not very good) is going to be working on it next, because it may very well
be true. What that means is that you can’t afford to write “fancy” or excessively “elegant” code.
The next person to look at it could end up making a mess because he or she doesn’t understand it.
I’ve discovered that writing code is like cooking: To please everyone, you can’t go for the escargot
or liver pate; you need to be serving steak and potatoes. Keep your code basic and straightforward,
and those coming behind you to maintain it will be able to do their job.

5: Assume the worst from your users
There is a bell curve of tech savvy with our users. We tend to miss the mark on usability and hit
the lower end of the bell, but that still leaves about 10% - 20% of users in the dark. Aiming for the
lowest common denominator means just that. With a few exceptions, you have to assume that the
person using your application will never look at documentation, attend training, or otherwise seek
out how to use your application.

6: Document the reason for a change
All too often, there will be a change in an application but no documentation of why the change
was made. A few months later, someone will notice that the change conflicts with another
requirement and demand to know why it was made, and no one will actually know. The next thing
you know, everyone will be losing a lot of time trying to figure out where the change came from
and why. By documenting the purpose of the change (and who the requester is), you’ll be saving
everyone a big headache down the road.

7: Explain the purpose of algorithms
In the same vein, any algorithm should have a clear explanation of why it was chosen. For
example, I support a CRM system that has a nonintuitive formula for applying discounts to
purchases. No one can quite explain why this specific formula is in place, but it is not working in
some scenarios. We are not quite sure how to change it, because the reason for its current form is
unknown. All it would have taken was a simple comment that said, “We do it like this because of
consideration CYZ,” and everything would be fine.

8: Provide contextual help
We all know that users tend to gloss over training materials. At the same time, it’s important to
provide a variety of contextually available help in your application. While users won’t read the
manual, they are likely to click the giant question mark next to the input control they don’t
understand. Put your help access as close to the UI controls as possible with targeted text to make
it easy for users to get the help they need. Also, remember to use terms and phrases your users will
understand, not internal jargon.

9: Perform cross-platform testing
If you are writing Web applications, it is important to test them on a variety of platforms. You will
want to check different browsers on different platforms. Sounds like a hassle, right? It is. Luckily,
there are some tools to help with that. Check out the offerings from Sauce Labs to make it a bit
easier to cross-platform test your Web applications.

10: Keep the users in mind
A lot of business requirements don’t help the users at all, and some may even annoy them. These
requirements may be non-functional but are designed to satisfy someone in the marketing or sales
departments. A great example is a registration page that asks for a lot more information (and
makes it mandatory) than most users feel comfortable giving. While I understand the motivation
(making their jobs easier), developers often underestimate how much users dislike it –while
overestimating users’ desire to get the benefits of registration. Remember that there are few unique
propositions in this industry, and you do not have the luxury of turning users away. Fight on behalf
of your users to make the best application possible.

What would you add?
What other good practices do you think are underused? Do you have any pet peeves you’d add to
this list?




Recommend Office .NET Component:


Spire.XLS for .NET

Spire.Office for .NET

Spire.Doc for .NET

Spire.PDF for .NET

Spire.DataExport for .NET

Mais conteúdo relacionado

Mais de Chen Stephen

A nightmare on elm street 2
A nightmare on elm street 2A nightmare on elm street 2
A nightmare on elm street 2Chen Stephen
 
A nightmare on elm street 2
A nightmare on elm street 2A nightmare on elm street 2
A nightmare on elm street 2Chen Stephen
 
How to prevent code rot
How to prevent code rotHow to prevent code rot
How to prevent code rotChen Stephen
 
5 ui tips for web apps
5 ui tips for web apps5 ui tips for web apps
5 ui tips for web appsChen Stephen
 
A developer's first impressions for windows 8
A developer's first impressions for windows 8A developer's first impressions for windows 8
A developer's first impressions for windows 8Chen Stephen
 
C# excel set excel number style
C# excel   set excel number styleC# excel   set excel number style
C# excel set excel number styleChen Stephen
 
C# excel bar chart
C# excel bar chartC# excel bar chart
C# excel bar chartChen Stephen
 
C# insert comments in word
C# insert comments in wordC# insert comments in word
C# insert comments in wordChen Stephen
 

Mais de Chen Stephen (9)

A nightmare on elm street 2
A nightmare on elm street 2A nightmare on elm street 2
A nightmare on elm street 2
 
A nightmare on elm street 2
A nightmare on elm street 2A nightmare on elm street 2
A nightmare on elm street 2
 
How to prevent code rot
How to prevent code rotHow to prevent code rot
How to prevent code rot
 
5 ui tips for web apps
5 ui tips for web apps5 ui tips for web apps
5 ui tips for web apps
 
A developer's first impressions for windows 8
A developer's first impressions for windows 8A developer's first impressions for windows 8
A developer's first impressions for windows 8
 
C# excel set excel number style
C# excel   set excel number styleC# excel   set excel number style
C# excel set excel number style
 
C# excel bar chart
C# excel bar chartC# excel bar chart
C# excel bar chart
 
C# insert comments in word
C# insert comments in wordC# insert comments in word
C# insert comments in word
 
Listview to dif
Listview to difListview to dif
Listview to dif
 

Último

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Último (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

10 good programming habits

  • 1. 10 Good Programming Habits Takeaway: Book learning will take you only so far. In the trenches, you need to develop sensible, effective habits like these. You learn lots of things when you go to college and get a computer science degree or read a how- to-program book. Unfortunately, a number of good programming habits are either untaught or take a good amount of practice to turn into a way of life. Here are 10 such habits you should cultivate to become a better programmer. 1: Learn your source control process You know that thing users like to do, where they pick up your application for the first time and get angry because it doesn’t do things exactly the way they want — and then they refuse to learn how the program works? You’re left scratching your head wondering why they didn’t bother to learn the application, which would have saved them all sorts of problems. Well, a lot of developers do that too, when it comes to working with source control. Every source control system is a bit different and has a workflow that maximizes the value you get from it. Learn that workflow! It may take some time, research, and practice, but trying to fight it by making your source control repository look like the ugly mess you are used to creating on your local hard drive defeats the purpose. You might as well just have good backups for your local system and call it a day. 2: Go with obvious variable naming This one comes up all the time: developers just give variables uninformative names and think it doesn’t matter. Well, it does matter any time someone else comes in to look at the code. I can’t speak for all developers, but I have yet to meet one who is typing for eight hours a day straight. Adding a few keystrokes for better variable names (especially when modern IDEs will autofill it for you) will make a measurable different in productivity. Stop making excuses and use better variable names. 3: Use interfaces, not classes when possible I violate this one all the time, and I know it. Whenever possible, code to an interface instead of a class. For example, if your class needs to return an enumeration of Integers, there’s no need to return a List<int>; return an IEnumerable<int>. This allows recipients to do what they want without needing to recast or transform the results into a class that meets their needs. 4: Assume the worst from your peers I’d love to think that everyone I worked with was as good, if not better than me at writing software. In some jobs, it was usually true; but in others, it wasn’t. I did learn, though, that you have to write your code as if someone with six months of experience (or someone with lots of experience who just is not very good) is going to be working on it next, because it may very well be true. What that means is that you can’t afford to write “fancy” or excessively “elegant” code. The next person to look at it could end up making a mess because he or she doesn’t understand it.
  • 2. I’ve discovered that writing code is like cooking: To please everyone, you can’t go for the escargot or liver pate; you need to be serving steak and potatoes. Keep your code basic and straightforward, and those coming behind you to maintain it will be able to do their job. 5: Assume the worst from your users There is a bell curve of tech savvy with our users. We tend to miss the mark on usability and hit the lower end of the bell, but that still leaves about 10% - 20% of users in the dark. Aiming for the lowest common denominator means just that. With a few exceptions, you have to assume that the person using your application will never look at documentation, attend training, or otherwise seek out how to use your application. 6: Document the reason for a change All too often, there will be a change in an application but no documentation of why the change was made. A few months later, someone will notice that the change conflicts with another requirement and demand to know why it was made, and no one will actually know. The next thing you know, everyone will be losing a lot of time trying to figure out where the change came from and why. By documenting the purpose of the change (and who the requester is), you’ll be saving everyone a big headache down the road. 7: Explain the purpose of algorithms In the same vein, any algorithm should have a clear explanation of why it was chosen. For example, I support a CRM system that has a nonintuitive formula for applying discounts to purchases. No one can quite explain why this specific formula is in place, but it is not working in some scenarios. We are not quite sure how to change it, because the reason for its current form is unknown. All it would have taken was a simple comment that said, “We do it like this because of consideration CYZ,” and everything would be fine. 8: Provide contextual help We all know that users tend to gloss over training materials. At the same time, it’s important to provide a variety of contextually available help in your application. While users won’t read the manual, they are likely to click the giant question mark next to the input control they don’t understand. Put your help access as close to the UI controls as possible with targeted text to make it easy for users to get the help they need. Also, remember to use terms and phrases your users will understand, not internal jargon. 9: Perform cross-platform testing If you are writing Web applications, it is important to test them on a variety of platforms. You will want to check different browsers on different platforms. Sounds like a hassle, right? It is. Luckily, there are some tools to help with that. Check out the offerings from Sauce Labs to make it a bit easier to cross-platform test your Web applications. 10: Keep the users in mind A lot of business requirements don’t help the users at all, and some may even annoy them. These requirements may be non-functional but are designed to satisfy someone in the marketing or sales
  • 3. departments. A great example is a registration page that asks for a lot more information (and makes it mandatory) than most users feel comfortable giving. While I understand the motivation (making their jobs easier), developers often underestimate how much users dislike it –while overestimating users’ desire to get the benefits of registration. Remember that there are few unique propositions in this industry, and you do not have the luxury of turning users away. Fight on behalf of your users to make the best application possible. What would you add? What other good practices do you think are underused? Do you have any pet peeves you’d add to this list? Recommend Office .NET Component: Spire.XLS for .NET Spire.Office for .NET Spire.Doc for .NET Spire.PDF for .NET Spire.DataExport for .NET