Thursday, December 20, 2012

Software architecture

Let me understand the real difference between "tire" and "layer" terms commonly used in architecture.

tire - referes to physical entity that is PC(s) and Server(s)
e.g - client machine running webbrowser, app serve running the web app, database server hosting the database. 

layer - refers to logical entity that is a component
e.g. userinterface layer, business logic layer, data access layer, database layer etc.

The conventiona asp or servlets, jsp or any web app that returns the html content and on the other side queries the database with SQL queries may not be a pure layered architecture because of the overlap of the layer reponsibilities.

A clean layered architecture could be

client - html, javascript, css client talking with a webservice using HTTP GET or POST, all presentation logic is part of javascript and css

dataaccess - webservice interfaceing with database using stored procedure (not SQL queries) to access data and return the data to the client in JSON or XML formats.

database - servers the webservice for the requested data using the stored procedures

The client machines can be many, the webservice if stateless can be
hosted in many servers for scalability reasons, the database server could be hosted in redudant high end server machines for availability reasons.

There are three logical "layers" and 3-tires but actually involving "n" number of physical machines.

client-HTTP(GET/POST)->webservice-TCP database connection ( to execute Stored Proc) ->DB
client<-http database="database" font="font" recordset-db="recordset-db" webservice="webservice">
 
No HTML is exchanged between client and webservice. 
No SQL command is issued by webservice to DB.

The above is a clean layered and tired architecture if the client, webservice and DB are deployed in different machines.

Reference: http://msdn.microsoft.com/en-us/library/aa905336.aspx

to be continued..

Wednesday, December 19, 2012

Auto Update

I am trying to understand how this software auto update might be working.
There could be three steps in it
1) Check for the availability of new version
2) Download the latest version
3) Install the downloaded version of software

Next i am going to expand on how each step could be designed or implemented

Check for availability of new version

When the current version of the application is started it could do the following in a background thread 1) Read the current version all the component that could be updated in the software
2) Go the vendor software update web server and check for the availability of newer version
2.1) Only if the exiting software license supports free updates
3) If newers version ar available the goto step2 or do nothing

Download the latest version

Options
1) Update the software user about the availability of newer version by displaying a message box and request the user for a manual update
2) Update the software user about the availability of newer version by dispaying a message box and request the user to intiate the auto download
2.1) Perform the download in the background (HTTP or FTP)

If download is successfully completed then goto to step 3 or display the error message to the user and the user to try again later.

Install the downloaded version of software

Note: Technology should support installation of newer version when current version of the software is running.
Install the downloaded software and request the user to restart the software.

Not sure how much of the above understanding and ideas are correct?

References
http://stackoverflow.com/questions/4499656/how-do-i-architect-automatic-update-of-my-clients


 

Thursday, August 30, 2012

Magic square!

Grid size:
 
What is row, column and diagonal?

diagonalcolumndiagonal
row
      
      
      
 
     

Magic square! is supported only on, Firefox 3 and above, Safari 3 and above, Google Chrome 3 and above and Internet Explorer 7 and above, web browsers.

Saturday, February 25, 2012

Scalability & Perfoamce

Load balance your website.
1) Use DNS (Domain Name Server) to distribute your website load.
2) Use Load Balancing Switch to distribute your website load.
The above mentioned load balancing methods work very well for static websites. But if your website have to do back end processing with a database or any other service, then even those services have to be load balanced otherwise they would become the bottle neck.

The above stuff is just the beginning of the vast topic called "Scalability"!
Abstraction interface
1) System abstraction interface help in hiding the complexity of the actual system and also the changes with in the system transparent to users of the system like hardware upgrade or adding hardware resource to scale up....
Scalability on the client

1) Paging concept (showing only few mail subjects on a mail client)

Scalability on the web/app server

1) multiple threads to handle http request
2) Load balancing architecture (one load balancing proxy server with multiple app server) to handle http request


External resources

Let's make the web faster
Web browser capabilities
Online web page testing
High Performance Web Sites and YSlow
Even Faster Websites
steve souders

to be continued.....

Android Findings

onConfigurationChanged - orientation change
Having "android:configChanges="orientation|keyboard" in manifest reloads the android activity on orientation change.
Instead the correct property is
"android:configChanges="orientation|keyboardHidden".

addJavascriptInterface - webview & javascript
When passing argument from javascript to android, pass it as string. Now if you want to convert the passed string to Integer or Long, the do not use Integer.getInteger instead use Integer.valueOf, that is, use valueOf.

Java Math.ceil with Integers
If your try to do some thing like
Integer a=1;
Integer b=5;
Integer c=0;
c=(int)Math.ceil(a/b);
You will get only 0;
Instead do something like
Integer a=1;
Integer b=5;
Integer c=0;
c=(int)Math.ceil((a * 1.0)/b);
So that you will get 1.

cursor.close() - Right place to close the sqlite cursor
Don't
if(cursor.getCount() > 0)
{
 cursor.close();
}
Do
if(cursor.getCount() > 0)
{

}
cursor.close();
Reference:https://groups.google.com/group/android-developers/browse_thread/thread/706258dfb7cbee1d