All posts by Pramod T P

Javascript Screen Objects

Screen objects are used to read the information from the client’s screen. The properties of screen objects are

  • AvalHeight: Gives the height of client’s screen Gives the width of client’s screen.
  • ColorDepth: Gives the bit depth of images on the client’s screen
  • Height: Gives the total height of the client’s screen, including the taskbar
  • Width: Gives the total width of the client’s screen, including the taskbar

Javascript Functional Components

The different functional components in JavaScript are-

First-class functions: Functions in JavaScript are utilized as first class objects. This usually means that these functions can be passed as arguments to other functions, returned as values from other functions, assigned to variables or can also be stored in data structures.

Nested functions: The functions, which are defined inside other functions, are called Nested functions. They are called ‘everytime’ the main function is invoked.

Javascript Deferred Scripts

By default, the parsing of the HTML code, during page loading, is paused until the script has not stopped executing. It means, if the server is slow or the script is particularly heavy, then the webpage is displayed with a delay. While using Deferred, scripts delays execution of the script till the time HTML parser is running. This reduces the loading time of web pages and they get displayed faster.

Magento Code Pool

codePool is a tag which you have to specify when registering new module in app/etc/modules/Company_Module.xml
There are 3 codePools in Magento: core, community and local, which are resided at app/code/ directory.
Core codePool is used by Magento core team, Community is generally used by 3rd party extensions and Local codePool should be used for in-hour module development and overriding of core and community modules for custom requirement.
So in short, codePool helps Magento to locate module inside app/code/ for processing.

Difference Between EAV And Flat Model

EAV is entity attribute value database model, where data is fully in normalized form. Each column data value is stored in their respective data type table. Example, for a product, product ID is stored in catalog_product_entity_int table, product name in catalog_product_entity_varchar, product price in catalog_product_entity_decimal, product created date in catalog_product_entity_datetime and product description in catalog_product_entity_text table. EAV is complex as it joins 5-6 tables even if you want to get just one product’s details. Columns are called attributes in EAV.

Flat model uses just one table, so it’s not normalized and uses more database space. It clears the EAV overhead, but not good for dynamic requirements where you may have to add more columns in database table in future. It’s good when comes to performance, as it will only require one query to load whole product instead of joining 5-6 tables to get just one product’s details. Columns are called fields in flat model.

MySQL SET

A SET is a string object that can have zero or more values, each of which must be chosen from a list of permitted values specified when the table is created. SET column values that consist of multiple set members are specified with members separated by commas (“,”). A consequence of this is that SET member values should not themselves contain commas.

Example

mysql> CREATE TABLE myset (col SET(‘a’, ‘b’, ‘c’, ‘d’));
Query OK, 0 rows affected (0.43 sec)

mysql> select * from myset;
Empty set (0.20 sec)

mysql> insert into myset value(‘p’);
Query OK, 1 row affected, 1 warning (0.23 sec)

mysql> select * from myset;
+——+
| col |
+——+
| |
+——+
1 row in set (0.10 sec)

mysql> insert into myset value(‘a’);
Query OK, 1 row affected (0.18 sec)

mysql> select * from myset;
+——+
| col |
+——+
| |
| a |
+——+
2 rows in set (0.00 sec)

mysql> insert into myset value(‘p,a’);
Query OK, 1 row affected, 1 warning (0.07 sec)

mysql> select * from myset;
+——+
| col |
+——+
| |
| a |
| a |
+——+
3 rows in set (0.00 sec)

MySQL CHAR And VARCHAR

Following are the differences between CHAR and VARCHAR:

  • CHAR and VARCHAR types differ in storage and retrieval
  • CHAR column length is fixed to the length that is declared while creating table. The length value ranges from 1 and 255
  • When CHAR values are stored then they are right padded using spaces to specific length. Trailing spaces are removed when CHAR values are retrieved.