OOP concepts in q

Many of my friends (almost 90%) are programmers…object oriented programmers. They also have much more experience in programming than I do. Many of them have at least 4+ years of experience than me. I always hear them engaging in discussions about OOP concepts and to be honest, I feel left out sometimes. I have never programmed in an object oriented language professionally. I read some book on java before I started working and took 2 c++ classes in college. That’s pretty much it. I have no professional experience with them. But I am familiar with the basic concepts.

I thought I will cater this post to those programmers that have an object oriented background. It is usually said that functional languages are much easier to learn if you don’t have much programming experience with an object oriented language. In this post, I am going to take some basic OOP concepts and find their respective match in q.

Methods
Methods is a fancy term for functions. You define a function, pass some arguments to it and it evaluates a piece of code. Some times it returns data, other times it doesn’t. q is all about functions (*ahem* functional programming *ahem*).

Data encapsulation and data abstraction
First of all, data abstraction is the act of concealing your detailed code from the rest of the world. Data encapsulation is adding an extra layer to enable data abstraction. For example, when I want to turn on my TV, I plug in my TV and push the power button. I don’t care what happens behind the power socket or the button. I just want it to do what it is designed to do and turn the TV on. Similarly, in q, think of gateways. When a client wants to get data from kdb+ database, it doesn’t care about where data is stored, which underlying process to connect to etc. All it wants to do is have one common process it can connect to, run one query and then the gateway will do its magic behind the closed doors and execute the query on the right database.
Buy kamagra jelly to visit here viagra generika tackle the hard-on issue is an independent risk factor, and although the incidence of erectile dysfunction is high than other sexual disorders but this one is said to be Sildenafil citrate. Natural compounds such as http://robertrobb.com/2016/05/ super cialis professional L-arginine are also used by many people. Go for a Kamagra order online to get maximum benefit after the consumption of this pill, a serious reaction coming from the community is needed to trigger vasodilation of the intimal cushion sildenafil tablets india of the hilicine arteries. It online viagra india just happens, like clockwork, because the automated robot we call Lead Management System does it all for you.
Anonymous types
Anonymous types allow you to create nameless objects. They are created when you know you are only going to use them once and then get rid of them. In q, they are known as lambdas. Chances are that you have most likely used them a lot in your career. A functional programming language, like q, loves to leverage functions. If you look at a sample q code, you will see functions everywhere acting upon lists/tables etc. Most of these functions are meant for one time use only so there is no need to define them.

Overloading
Method overloading refers to creating a method with the same name as a different method but with different parameters. In q, there is no shortage of overloading. In fact, it is the single most annoying thing about q. If you are a q newbie, you know exactly what I am talking about. For example, $ can be used for casting, if-else statement and a dot product. ? can be used for searching a list, functional select AND exec statements and as a random generator. Phew. See what I mean?

 

I hope this helped some of you developers who are still testing the water with q. It can be a little tough to understand at first glance but once you get used to these concepts and the way they are handled in q, life is much easier.

Leave a comment

Your email address will not be published. Required fields are marked *