Friday, December 3, 2010

Limitations of SQLite version 3

Found a good source of Limitations of SQLite embedded database. And I am quite impressed about the numbers that have as a limit in any category. I my opinion those are not limitations Open-mouthed smile. Rather those are supports. You can take a look at this http://www.sqlite.org/limits.html where all the max stuff is listed. Here are few examples, and all are taken from the original site.

Maximum Number Of Rows In A Table

The theoretical maximum number of rows in a table is 264 (18446744073709551616 or about 1.8e+19). This limit is unreachable since the maximum database size of 14 terabytes will be reached first. A 14 terabytes database can hold no more than approximately 1e+13 rows, and then only if there are no indices and if each row contains very little data.

Maximum length of a string or BLOB

The maximum number of bytes in a string or BLOB in SQLite is defined by the preprocessor macro SQLITE_MAX_LENGTH. The default value of this macro is 1 billion (1 thousand million or 1,000,000,000). You can raise or lower this value at compile-time using a command-line option like this:

-DSQLITE_MAX_LENGTH=123456789

The current implementation will only support a string or BLOB length up to 231-1 or 2147483647. And some built-in functions such as hex() might fail well before that point. In security-sensitive applications it is best not to try to increase the maximum string and blob length. In fact, you might do well to lower the maximum string and blob length to something more in the range of a few million if that is possible.

During part of SQLite's INSERT and SELECT processing, the complete content of each row in the database is encoded as a single BLOB. So the SQLITE_MAX_LENGTH parameter also determines the maximum number of bytes in a row.

The maximum string or BLOB length can be lowered at run-time using the sqlite3_limit(db,SQLITE_LIMIT_LENGTH,size) interface.

Maximum Number Of Columns

The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. On the other hand, many experienced database designers will argue that a well-normalized database will never need more than 100 columns in a table.

In most applications, the number of columns is small - a few dozen. There are places in the SQLite code generator that use algorithms that are O(N²) where N is the number of columns. So if you redefine SQLITE_MAX_COLUMN to be a really huge number and you generate SQL that uses a large number of columns, you may find that sqlite3_prepare_v2() runs slowly.

The maximum number of columns can be lowered at run-time using the sqlite3_limit(db,SQLITE_LIMIT_COLUMN,size) interface.

Maximum Number Of Tables In A Join

SQLite does not support joins containing more than 64 tables. This limit arises from the fact that the SQLite code generator uses bitmaps with one bit per join-table in the query optimizer.

SQLite uses a very efficient O(N²) greedy algorithm for determining the order of tables in a join and so a large join can be prepared quickly. Hence, there is no mechanism to raise or lower the limit on the number of tables in a join.

Note: I am sure those are pretty good numbers as far as an embedded database can offer.

Friday, November 12, 2010

Prevent WPF Tree View nodes from getting selected.

By default all the nodes of the WPF tree view is selectable. If some how we had a requirement that the roots nodes can not be selected rather only the child nodes will be selectable we need to customize one single property “focusable”. If we set the focusable property of any node to false then the node will not be selectable. pretty small thing but worth sharing because in MSDN forum one developer asked for this.

Bello a simple code sample is given

        <TreeView Height="251" HorizontalAlignment="Left" Margin="45,30,0,0" 
Name="treeView1" VerticalAlignment="Top" Width="197">
<TreeViewItem Header="Yahoo" IsManipulationEnabled="False" Focusable="False">
<TreeViewItem Header="d" />
<TreeViewItem Header="c" />
<TreeViewItem Header="b" />
<TreeViewItem Header="A" />
</TreeViewItem>
</TreeView>






Hope this will help, Note that if you have some binding with the tree grid and you want to achieve the same as above you might need to use triggers.

Friday, October 8, 2010

Most widely used WPF client application development frameworks

I done some research on WPF client application development frameworks and eventually found out three most used framework and one yet to be mature framework. I thought its worth sharing the research result

1. Prism

http://compositewpf.codeplex.com/

Impression : Most advance framework

2. Caliburn

http://caliburn.codeplex.com/

Impression : Advanced  framework

3. Cinch

http://cinch.codeplex.com/

Impression : Solved particular set of problems and can be used along with other framework

4. WPF Application Framework (WAF)

http://waf.codeplex.com/

Impression: Primitive and useful framework to develop MVVM pattern based application

All the application framework used MVVM pattern to develop the applications, I am sure this frameworks are worth learning and will definitely help us in career.

Friday, September 10, 2010

Typical Code Smells

While doing daily development in various project we often found lots of coding standard problem, we just don’t know the appropriate vocabulary for that, Today I am providing a list of all code smells that can be found in codes, We would elaborate and learn about each code smell. the list (rough) is given bellow, if anyone finds more code smell please provide in comment section.

  1. Dead code
  2. Duplicate code
  3. Comment
  4. Long Method
  5. Large Class
  6. Oddball Solution
  7. Primitive Obsession
  8. Switch Statement
  9. Speculative Generality
  10. Long Parameter List
  11. Conditional Complexity
  12. Combinatorial Explosion
  13. Alternative classes with Different Interfaces
  14. Inappropriate Intimacy
  15. Indecent Exposure
  16. Refused Bequest
  17. Black Sheep
  18. Data Class
  19. Solution Sprawl
  20. Feature Envy
  21. Temporary Field

In future post we would discuss mostly all about the smells.

Sunday, August 15, 2010

Is Excel Present in client machine?

In one of our application we had to make sure that whether client have excel installed or not. We tried few codes and have some experience while resolving the solution. Bello the solution code is given to detect if client have excel 2007 installed or not.
 
The bellow code works fine. But it fails one single time. If the user installed excel but never run it. The registry keys are not built until the user run excel for the first time. so we had to change our message to inform user as “You don’t have excel or you didn’t run it after install, if you have install please run it for the first time and try again” some thing like this.
 
private static bool IsExcelPresent()
{
var key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Office");
if(key!=null)
{
string[] subKeyNames = key.GetSubKeyNames();
if(subKeyNames.Contains("12.0"))
{
var excelKey = key.OpenSubKey("12.0\\Excel\\");
if(excelKey!=null) return true;
}
else
{
return false;
}
}
return false;
}


 

Eventually we got rid of the obstacle and found a very interesting component called SpreadsheetGear and used that component. we bypassed all the excel requirement using this component.

 

There are some more solutions on the web to you guys can also try those. Bellow a yet another code sample is given.

 

private static bool IsExcelPresent()
{
try
{
Type officeType = Type.GetTypeFromProgID("Excel.Application");
return officeType != null;
}
catch (Exception ex)
{
return false;
}
}


Another code sample to detect excel which using registry key search

 

private static bool IsExcelPresent()
{
RegistryKey key = Registry.ClassesRoot;
RegistryKey excelKey = key.OpenSubKey("Excel.Application");
bool excelInstalled = excelKey == null ? false : true;
return excelInstalled;
}


 

 

Thursday, July 15, 2010

Simple Yet powerful html Content rotator

I found this simple yet powerful html content rotator and using in few of my projects. I think its worth sharing with the community. The library named

jShowOff: a jQuery Content Rotator

You can download the script from this location. It requires two file only, on css which you can copy to your own css file and the other one is of course the java script , there are two distribution for this library, I strongly suggest that you should use the min version.

http://ekallevig.com/jshowoff/

There are some comprehensive set of examples given in the home page for the library. I would suggest to download and look for this examples.

image 

Best of luck and happy programming.