10 Tips for Better Coding - Deepstash
10 Tips for Better Coding

10 Tips for Better Coding

Curated from: sitepoint.com

Ideas, facts & insights covering these topics:

8 ideas

·

2.25K reads

24

Explore the World's Best Ideas

Join today and uncover 100+ curated journeys from 50+ topics. Unlock access to our mobile app with extensive features.

1. Use a Coding Standard

1. Use a Coding Standard

It’s easy to write bad, unorganized code, but it’s hard to maintain such code. Good code typically follows some standard for naming conventions, formatting, etc. Such standards are nice because they make things deterministic to those who read your code afterwards, including yourself. Use something like StyleCop to practice good habits.

46

433 reads

2. Write Useful Comments

2. Write Useful Comments

Comments are crucial. You won’t appreciate them until you leave your thousand-line script for a couple of days and return to and try and make sense of it. Anyone who can read code knows WHAT the code is doing. Explain WHY you've done it this way. 

44

311 reads

3. Avoid Global Code

3. Avoid Global Code

Global variables and loops are a mess and can prove problematic when your application grows to millions of lines of code (which most do!). They may influence code elsewhere that is difficult to discern, or cause noisy naming clashes. Think twice before you pollute the global namespace with variables, functions, loops, etc. ALWAYS USE NAMESPACES.

43

315 reads

4. Use Meaningful Names

4. Use Meaningful Names

Never use names like $k , $m , and $test for your variables. How do expect to read such code in the future? Good code should be meaningful in terms of variable names, function/method names, and class names. Some good examples of meaningful names are: $request , $dbResult , and $tempFile (depending on your coding style guidelines these may use underscores, camelCase, or PascalCase).

38

260 reads

5. Use Version Control Software

5. Use Version Control Software

Managing changes and revisions should be easy but effective, so pick whatever version control software that will work best with the workflow of your development team. I prefer using a distributed version control tool like Git or Mercurial; both are free software/open source and very powerful.

41

232 reads

6. Use Automated Build Tools

6. Use Automated Build Tools

Try to use tools like Ant or Phing to get your source prepared, compressed, and deployed. Building your whole application with a single command is a marvelous way to prevent errors and omissions that are inherent when performing repetitive tasks.

40

240 reads

7. Use Code Documenters

7. Use Code Documenters

For large applications spanning several classes and namespaces, you should have automatically generated API documentation. This is very useful and keeps the development team aware of “what’s what.” And if you work on several projects at the same time, you will find such documentation a blessing since you may forget about structures switching back and forth between projects.

40

216 reads

8. Write tests

8. Write tests

It's easy to overlook writing tests for a simple application, but as they grow in size it becomes increasingly important to be sure a change in one location after a time doesn't break something. Having tests makes sure the specific process you're testing always stays functional as intended.

41

250 reads

IDEAS CURATED BY

genevra

hi I'm Gen 🪄 🔮 it was fated that we meet

Gen 's ideas are part of this journey:

Machine Learning With Google

Learn more about computerscience with this collection

Understanding machine learning models

Improving data analysis and decision-making

How Google uses logic in machine learning

Related collections

Read & Learn

20x Faster

without
deepstash

with
deepstash

with

deepstash

Personalized microlearning

100+ Learning Journeys

Access to 200,000+ ideas

Access to the mobile app

Unlimited idea saving

Unlimited history

Unlimited listening to ideas

Downloading & offline access

Supercharge your mind with one idea per day

Enter your email and spend 1 minute every day to learn something new.

Email

I agree to receive email updates