Coding Tricks for Oracle Developers

, , ,

Being a developer is hard. We tend to strive to make the best, most precise code. We tend to try to keep it clean and readable in case somebody else might need to review it and work on it in the future. However sometimes we believe our code is clean and as it turns out, once you are done, you realize that your code might be confusing for another developer or you might want to reuse your code and might find yourself updating it several times in different sections. Fortunately, there are several tricks that are useful in helping you make your code simpler and reusable. Below are 3 tricks I follow when developing a script (PHP, Javascript, Groovy, etc) for any Oracle CX system.
 

  1. Use Camelcase Syntax

Camelcase syntax is the writing of compound words or phrases where each word or abbreviation in the middle of the word begins with a capital letter with no spaces between them. For example “iPhone”, “JohnDoe”, etc. This syntax is helpful in keeping your code clean and readable. Mostly used for declaring functions and variables this syntax will look something like this in php scripting:

 

                Declaring a function with variables in it:

                

               

  1. Use Comments

Comments are a programmer's readable explanation in the source code. These are used with the purpose of making the script easier to understand for people that might be working with the script in the future. The syntax varies depending on the programming language, with the most common of them being that comments start with “//”. You can also use a block of comments to write documentation, these generally start with “/*” and end with “*/”. Below you can find our previous example with comments added to it.

 

  1. Use Code Golf

Code Golf is the term used to describe the technique of writing code that can be reusable. In other words the less code you can write the better. This technique is usually applied when you develop a big project that can have thousands of lines. A good example would be if you need to get information from a MySQL database for 5 different tables, the first idea would be to write 5 separate functions to get the data from the 5 places. Using the code golf technique we can reduce these functions to one by sending the table name inside a variable to the function before we execute it, and then reusing that same function by changing the value of the variable every time we need to. To end result would be that you will have a clean code without it being thousands of lines long.

 

Conclusion

Having been a programmer/developer for the past 8 years has shown me that by using these techniques, you can reduce the amount of work you do, you can understand the code in a more humanly way, and you will be able to reuse your creation for different purposes. At the end of the day the goal is to make your customers happy, and what better way than by making their application the best one there is.