How to Code Like a Pro

thumbnail for this post

So you are a programmer, huh? You want to write cool and really sophisticated code. Like a pro? Here is my list that can help you to get started.

Choose programming language like a pro

First, you need to choose a language that you will use to implement your apps. Your language of choice defines how good of a programmer you are.

  1. Use new and exotic programming languages. Real pros use cool languages, not that mainstream crap that everyone else is using. Try Haxe or EmberScript. And don’t forget to convince everyone that it is way better than anything they have used before.
  2. Use old, time-tested programming languages. All those new hippie languages are not for everyone. If you are old-school - use something proven by time. Like C++98, Perl or PHP3.
  3. Stick to your language of choice and never betray it. Use it for everything and refuse to learn any other heresy.

Design application like a pro

Dependency graph of a real pro

Design is the most important part of your application. Your design must be complex and sophisticated. Only real pros should be able to understand it.

  1. Use all design patterns that you know. You just finished the Gang of Four book, time to put it into practice, right? Use as many patterns as you can remember.
  2. Learn even more patterns and use them. The more patterns you use in your application, the more of a pro you are.
  3. Use Singleton as much as possible. This is your most important pattern. There can be only one AbstractAdapterBuilderFactory in your application, right?
  4. Create your own format for configuration files. It will be 100 times better than existing ones. If you feel lazy, just use XML.
  5. Download configurations from remote server. And make sure part of it is generated.
  6. Use Frameworks for everything. Logging framework, object instantiation framework, annotation framework, frameworks of frameworks.
  7. Especially, dependency injection frameworks. Even if your application consists of 3 classes.
  8. Design your application to have as many layers as you can. The more, the better.
  9. Add more dependencies. If you want your application to be dependable, your components must depend on each other. All of them. Also, depend on as many libraries as you can. And don’t forget to add a circular dependency or two.

Implement like a pro

Implement like a pro

Design of application is important, but your implementation is the first thing others will see. Make sure they realize that they see pro-level implementation. Here is how you can achieve it.

  1. Create interfaces for every single class. Interfaces are cool. Every class should have an interface and only one default Impl class.
  2. Make all your classes generic. Specialization is for noobs only. What if your rectangle needs to have 5 corners?
  3. Use names that only you can understand. ‘avr_gdf_qww’ is a totally legit name for a variable. ‘do_stuff()' is a good name for a function.
  4. Never alow logic of your function to be obvious from the first glance. Use code branching, nested ‘if’ conditionals, and switches as much as possible.
  5. Use side effects. If your function adds two variables, why don’t it also increment the first one? It should also sort global array and flip a few global boolean flags.
  6. Modify input arguments in your function. Your functions must show authority, or no one will really respect them. They can do whatever they want with variables they are given.
  7. Make everything implicit. The more is done by ‘magic’ - the less others will understand and the smarter you will look to them.
  8. Generate as much code as you can. Better, generate code that will generate code.
  9. Use try/catch everywhere. Wrap any function call that you doubt in try/catch. Better wrap all your logic in try/catch and don’t let any single exception to slip away.
  10. Use exceptions to control execution flow. They are almost as good as GOTO statement.
  11. Create custom exceptions for everything. Built-in exceptions are just not good enough.
  12. Put all your code into one file, or into one giant class if your programming language allows that. Your code must be monstrous and instill fear.
  13. Use long functions. Size matters! The longer the function, the more sophisticated it is, the better programmer you are. No less than 800 lines.
  14. Re-use variables for performance optimization. If you already have a variable called ‘square_root’, why can’t it contain local time a few lines down? It is already there, right?
  15. Global variables are your friends. Especially mutable ones.
  16. Implement your own copy, equals, to string functions. You can do it better than the standard library. I believe in you!
  17. Pass as many arguments to functions as you can. If constructor has less than 12 arguments, no one will take it seriously.
  18. Any good function must take at least 3 boolean parameters. And a callback function.
  19. Use boolean flags for everything.
  20. Use inheritance intensively. All your classes should derive from a common base class.
  21. Use multithreading for everything. Write your own syncroniztion primitives.
  22. Write your own serializers for everything and develop your own serialization formats. JSON is so 2000.
  23. Handle dates and time conversion yourself. Never trust standard implementations. Who knows what they put in there?
  24. Make all your fields and member variables public. You have no secrets.
  25. Don’t ever write unit tests. Those are for QA. Good programmers write good code right away.
  26. Never refactor. Masterpiece of your creation should live forever for future generations to behold.

Summary

If you follow these simple commandments, my friend, you will be the most respected coder in your company. Only you will be able to understand your code, let alone change it. Bonus points if after a week even you cannot understand it!

What are your secrets to code like a pro? Share in comments below!

P.S. It would have been funny if it wasn’t sad. Unfortunately, I had a ‘pleasure’ to encounter all those and many more throughout my career.

Title image is from New York Times

See Also

What Programing Language to Learn Next?

According to Wikipedia, there are over 700 programming languages in the World. How do you decide which one to learn next? Let’s explore several ideas.

How to stop fearing job interview and perform better

Did you ever have troubles sleeping the night before important job interview? Have you ever felt your heart racing and palms sweating during an interview? If so, you are not alone.

Doing More With Pomodoro Technique

Wishing you had one extra hour every day to get more done? Probalby yes. Would you be even more productive if you had 30 hours a day?

comments powered by Disqus