Category Archives: Software

Software Related Posts

Design Patterns…Some Basics

Here are some basic terms before we get into actual patterns
1. Object packages both data and procedures
2. Procedures are called methods
3. Object performs a operations on a request/message.
4. Encapsulation is a concept due to which u can only change the state of the object using methods
5. Signature of method is defined by name, parameters and return value.
6. Interface is set of all methods defined by an object.
7. A type is a subtype of another if its interface contains the interface of its supertype.
8. The runtime association of a request to an object and its operation is called dynamic binding.
9. Object implementation is defined by its class. The class defines objects data and operations it can perform.
10. Object is created by instantiating a class.
11. New classes can be defined based on exisiting classes using inheritance.
12. Subclass inherits from a parent class.
13. Abstract class defines common interface for its subclasses. You cannot instantiate a abstract class.
14. Subclasses can override a operation defined in parent class.
15. Mixim class provides an optional interface. Only available in multiple inheritance.
16. Reusability can be achieved by inheritance or object composition. In inheritance sub class has access to all internal info of parent class. In Object composition it can only use the interface to access the composed class.
17. Delegation helps in forwarding a call coming to the main object to the composed object. This makes composition equivalent to inheritance.
18. Templates/parameterized types are a way of defining types without defining all the types it uses.
19. Aggregation is a when one object is part of another object. There life times are identical
20. Association/Acquintance is when 2 object just know each other and can call each others methods.
21. Toolkit is set of predefined libraries.
22. Framework is set of classes that make up a reusable design for class of software.

Design Patterns…

Architecting a new system. It is an amazing thing to do. Giving birth to something new, nuturing it and seeing it blosom, changing it based on new surrounding and requirements this is what Architecting is all about… In this series I will try to talk about a concept called Design patterns and how it can be used in Object oriented desings.

Desinging a object oriented system is not simple. You really need a lot of experience to get it really correct. The whole basis for OOD is reusability and extensibility… A good OO system is the one in which u can reuse majority of the components. Now how do we design a OO System? By reusing the concepts used in successful OO systems. Always remember you are not the first guy to face a problem. So many people have built so many systems and surely someone has faced a similar problem and hopefully he has used a successful technique to solve the problem so just reuse his technique. This is the concept behind patterns… Every problem you face has a pattern linked to it and you can apply existing solutions to the patterns thus simplifing the designs. This is true for any kind of environment not just OO systems…:) How do you thing such big building, bridges, ships… built…???

Every Pattern has 4 elements
1. Pattern Name: To identify the pattern.
2. Problem: Situation under which the pattern can be applied.
3. Solution: Element that makes the design, their relationship, responsibilites and collaboration…
4. Consequences: Results and trade-offs of applying the pattern.

Hope this series helps everyone…

SQL Lite Database with Python

How do you connect to SQL Lite database using Python?

Simple just download pysqlite. This is an open source solution. You can download it from Once you install this you have everything u need to connect Sql lite via Python. Here is an example how you can execute an sql statement and parse it…


>>> from pysqlite2 import dbapi2 as sqlite

>>> con=sqlite.connect(“customers.db”)

>>> cur=con.cursor()

>>> cur.execute(“select * from items”)

>>> for row in cur:

… print ‘code is %s name is %s and price is %d’ % (row[0],row[1],row[2])

SQL Lite database

We have decided to use SQL lite database for our next project. For next few weeks/days I will try to update the blog with SQL lite related stuff…SQL Lite is a very simple database which can either be run in memory or from file system. To get more details about the database itself, please visit


  1. Creation of Database

Sqlite3 customer.db

  1. Create a Table(SQL)

 create table items(itemcode string(10),itemname string(25), price double(100,2))

  1. Insert data into table

insert into items values("itm0001","Milk",10);

insert into items values("itm0002","Curd",15);

  1. Select table data

Select * from items

  1. Delete table data

delete from items where itemcode="itm0002";

  1. Drop a table

Drop table items;


Simple database stuff right… I know. But this is the beginning… Now how do we connect to this database from python? I have never used python…L Also how do we link python in apache and then call the database and update stuff coming from a web application…J Wait for more…


How to use Events in .NET?

Events and Delegates are the best features available in .Net compared to Java. Event handling seems to be a complex thing actually it is not. It is very simple. Here it is…


  1. Define a delegate: It is just a function definition

            public delegate void EventReceiver(object sender);


  1. Define a event and make it type of delegate.

         public event EventReceiver someobject;


  1. Call the event: Based on your logic call the event

If BLA BLA BLA BLA BLA and (null != someobject)

               someobject (this); //simple


  1. Define a function with same specs as the delegate

public void somehandler(object sender)


//Some code here


  1. Register ur function to receive the events

SenderObject.someobject += somehandler;


Done… Finisho It is that simple…


HEX conversions in dotnet and java…

Some time in your applications you will have to convert a Hex string into and integer and a integer into Hex string. Following is the syntax to perform this conversion in Java and .NET.
Convert from int to String
String stringValue = intValue.ToString(“X”);
Convert from String to Int
int intValue = System.Convert.ToInt32(f_MaskValue,16))
2. Java
Convert from int to String
String stringValue = Integer.toString(intValue,16);
Convert from String to long
Long value = Long.parseLong(stringValue,16))