Abstract Confusions

Complexity is not a cause of confusion. It is a result of it.

Category Archives: Technology

Commenting your code

It’s been a while since I blogged. I was actively following lot of topics, but mostly held my thoughts to myself from writing.

One such article I read was: Who needs comments? My code is self-documenting! aka: Comment tersely with value-added information.

The author makes the following point:

/* If the first field of the properties record is N... */
IF master_list(l_curr_index).properties_flag.field1 = 'N' THEN
a better way of writing it would be
/* If the customer is not eligible for a discount... */
IF customer_not_eligibility (l_curr_index) = 'N' THEN
As part of the suggestion, he suggests it is better to write a function, and code the business validation. Once that is done, there is no need for the preceding comment. The function is self explanatory.
I know coding style differs. But I am particularly edgy about a function returning TRUE for a negative check (I know, I know, it is just me, but still saying). I would rather rewrite the following:
IF customer_not_eligible (l_curr_index) THEN


IF NOT customer_eligible (l_curr_index) THEN

this way, I can use the same function to see if the customer is eligible (otherwise, you would be doing, “IF NOT customer_not_eligible (l_curr_index) ” which is double negation and could be confusing.

How would you do?

Some Interesting Requirements / Questions

Over the time I received few interesting requirements and questions. Few of them are straight forward that you do it in minutes, and few other questions are strange enough that some time have to sit and etch out the solution which is not top of the head. It would be only fair to share the information here. I would give you the requirement / question, if you can answer them, please add in comments.

You can use any language you like (except 3rd requirement). I was forced to use PL/SQL because of the project requirements.

Read more of this post

Oracle Application Express (APEX) Interview Questions

Oracle Application Express (APEX) is a rapid application development tool developed by Oracle for developing rich database centric applications. It first started as HTMLDB and later renamed as Application Express, though it is often shorten as APEX. APEX is a free feature that can be enabled from Oracle database v 9.2 onwards. It means, Oracle Application Express can be installed with the free version of Oracle 10g Express Edition. It is easy to create and run web applications which look professional and scalable. Of recent there is increased interest on APEX skills.

I had an opportunity to interview few people for evaluating their APEX skills. Following is the selected set of questions I used in that interview. The difficulty level is basic to intermediate level. The main idea is to identify the promising people who had real experience on APEX. I have added links to the concepts, documentation. Read more of this post

Compound Trigger – A Performance Improvement for Trigger Executions

In Oracle database 11g release version 1, among the enhancements in trigger execution an important and efficient feature known as ‘Compound Trigger’ is rolled out. This feature is particularly exciting because of the performance improvements it may bring in along with it.

Auditing Bulk INSERT/UPDATE of a Table Efficiently

Assume you have a transactional table, this table is highly accessed by a front end application which does a lot of inserts and updates every minute. You also have a functional requirement of keeping track of the changes against the values inserted / updated. The traditional setup one would have for such a scenario is to write a separate trigger each for AFTER INSERT and AFTER UPDATE to fetch the values and insert them into an auditing table as well. Read more of this post

Haskell – A Functional Programming Language

Functions in mathematics are like building blocks in many fields. Functions are also widely used in physics and other branches of engineering. In computer science, functions play a major role.  When you have a mathematical function and want to write a program for that, most of the time you do it line by line, with the program constructs like looping, conditional looping and other control structures. This could run to several lines of code.

Functional Programming

Unlike the programming languages like Pascal, C, C++ and all other higher programming languages thereof, are known as imperative programming or structured programming languages. Imperative program is executed using statements described steps after steps. Functional programming is programming executed by evaluating expressions (or functions).  There are no variable assignments, on the higher side, functional program contains no side effect at all. Read more of this post

Trigger Enhancements in Oracle 11g Release 1

Prior to Oracle 11g Release 1, if you have two (or more) triggers on a table for same action – event (BEFORE, AFTER – INSERT, DELETE, UPDATE), there is no guarantee in which order there will be fired. Oracle database 11g Release 1 has introduced improvements in triggers.

On Order of Execution of Multiple Triggers

Prior to Oracle database 11g, developers can never assure you the order of execution of triggers. If you have more than one trigger set on the same triggering conditions, Oracle documentation says that, the order of execution will be random.

Oracle fires multiple triggers in an unspecified, random order, if more than one trigger of the same type exists for a given statement; that is, triggers of the same type for the same statement are not guaranteed to fire in any specific order.

This was a hindrance in many scenarios. Most of the time PL/SQL developers would do away with this in simple manner. They will write one trigger and let it to call all other similar triggering actions. Although this doesn’t look like a good practice, it was at least better than to leave it for Oracle to decide at random. Read more of this post

Dynamic Typing – New Feature in C# 4.0

Microsoft has released a new version of its flagship product .NET. Visual Studio is highly productive environment for professional to develop and deploy .NET frame work applications. But it still lacked few features which if present would have been better. One of those features is ‘dynamic programming or dynamic typing’. A new version Visual Studio 2010 is released recently. C# 4.0 has this feature.

Dynamic Typing / Dynamic Programming

Dynamic typing as it is known famously has more advantages over static typing. More often people note that, in a statically typed language, a variable – the name, is bound to an object and also bound to a data type. The data type a variable takes needs to be known at the compile time itself. It is true in Java, C and C++.

In a dynamically typed language, the variable, the name is bound to only object. The data type is not declared up front. All happens in runtime. Pretty much true with programming language Python. Now, with Visual studio 2010 release, we will have C# 4.0. C# 4.0 also has dynamic typing feature now. Read more of this post

Interesting Interview Question: Check if a String is Rotated

Found an interesting interview question at Stackoverflow.

How will you find a string ‘a’ is a rotated string of some string ‘b’ (say, or some other reference string, but known)?

a= ‘stackoverflow’, b = ‘overflowstack’, then ‘a’ is rotated string of ‘b’.

a= ‘stackoverflow’, b= ‘flowrevostack’, then ‘a’ is NOT rotated string of ‘b’.

What makes this interview question interesting is seemingly difficult question (check Jon Skeet’s answer, he admitted the actual answer is simple and elegant).

Read more of this post

Oracle: On Functions Returning Two or Multiple Values

Mathematically, a deterministic function always returns same value no matter how many times you call. An exception is random function. Any function which involves a random functions will return different values at different times. Here, we are going to discuss about a deterministic Oracle function returning multiple values. To put it simple, In Oracle, can a function have two OUT parameters? In short, yes.

In Oracle, we always know that a function can and should return a value. Is it possible to send two return values?


Oracle Database and Partial Differential Equations (PDE)

I was going through this website and found this interesting offer on Oracle Database 10g: Complete Reference. This wonderful book is sold for INR 63 (+100 for handling and postage), and in total INR 163 with companion CD. It still worked out to a good deal. Until I found the related titles, which the site suggested, “If you like the above item, you might also like the following items:” and listed down books from Partial Differential Equations (PDE).

Now, please don’t get angry. Either there has to be hidden connection between Oracle and PDE or the site some how read my mind. You can also try and it might still show up to you. Even I would like to know where there is any relation between Oracle Database and Partial Differential Equations.