Posted on 18,856 Comments

Web Application VS Desktop Application

Which one is better?

The end-users generally don’t care whether the application is desktop, web, or mobile, they only want their task to get done efficiently, easily, and fast.

There are continuous improvements in the development of software, whether it is in the user interface (UI), user experience (UX), deployment, or in technologies. It is also observed that the changes are taking place every five years. Shifting from Desktop to Web, Web to mobile APK, Web, and APK to Desktop, Progress Web Page (PWA), Cloud hosting, etc., client-server, multi-tier, XML to JSON, SOAP to REST. Each solution and platform has its own strength and weakness.

Suppose we want to provide flight services to our customers to go from Kathmandu to Pokhara and vice versa. What solution we choose from following two options:

  1. Flight solution using Boeing 777 (max speed of 900+ km/hour, max pax 300+ )
  2. Flight solution using ATR 42 (max speed of 400+ km/hour, max pax 40+)

We have to select the option based on distance, speed, number of pax, runway facilities, investment, return etc. Similarly, the software solution has to be selected based on requirements and other resources available.

Everything in this world is subject to change. I have a very clear understanding of this context. Nothing is permanent. Market changes, a test of users change requirements changes, the environment changes, working habits changes, looking at the products and services change. In order to go ahead, we must embrace or accept the CHANGE. However, the CHANGE has to be evaluated properly before we adopt it as it could have an impact on many aspects including cost and other resources. Let us get back to our main point Desktop vs Web application and which one is the best?

Over the past decade, there is a constant debate about web apps and desktop apps. Which is better, what are the differences? Which one should be considered for our solutions?  Let us analyze its pros and cons.

What is a Desktop Application?

A standalone application you can install on a computer to carry out a specific task is a desktop application. It can talk to the centralized database server through a VPN. Examples of this type of software are Word, Excel, Powerpoint, Pumori, etc. It utilized the resources of PCs for execution as a result its performance is always better in comparison to web applications.

What is a Web Application?

A web application is software that runs on the web browser and utilizes web technology to carry out different tasks on the web. It requires an internet connection. It uses mostly the server resources and client validation and rendering is done on local PCs. So the utilization of PCs resources is minimum but there are no supplies of PCs with minimum resources nowadays. In this connection, the resources of PCs are wasted. Some of the most common examples of web apps include Google sheet, Google DOC, etc.

What is a Mobile Application?

A mobile application (also called a mobile app) is a type of application (APK similar to EXE files) designed to run on a mobile device, which can be a smartphone or tablet. Examples of mobile apps are Viber, Skype, Facebook etc. Note that mobile apps are similar to desktop apps which have to be downloaded to be used in devices.

Comparision

FactorsWeb AppDesktop AppMobile App
AccessibilityCross-PlatformOS-SpecificDevice-Specific
InstallationAutomaticManual/Can be automatedManual/can AutoUpdate
UpdatesServer updateUpdate in Multiple ComputersAuto Update
UpdatesServer updateUpdate in Multiple ComputersAuto Update
Internet ConnectionRequiredNot RequiredCan be offline, Sync when online
OS FeaturesRestricted OS FeaturesCan Access All FeaturesCan Access Device features
ResourcesUtilizes fewer computer resourcesCan utilize computer resources as per needCan Utilize Device resources
PerformanceGoodBestBetter (Faster than Web)
Platform DependencyNoYesYes
SecurityConsidered Less secureConsidered More SecureConsidered Secured
Forward FixingEasyHardModerate
Maintenance RollbackHardEasyModerate
Data EntrySlowFastSlow
Investment on Server HWHighLowHigh
HostingRequiredNot RequiredRequired
MobilityYesNoYes
Platform DependencyNoYesYes
DeploymentEasyDifficultModerate
Performancedegrade when added Heavy FeaturesCan add heavy featuresRestricted
DevelopmentExpensiveEconomicExpensive
Access to system resourcesNOYesYes
Native AppNoYesYes

My Openion:

I hope that you have understood the difference between web apps vs desktop apps.

From the comparison, you must have understood that every application has its own pros and cons, and they can be utilized for specific requirements.

Why mobile apps, web apps like Skype, Viber, Zoom are given as desktop apps for PCs. The reasons are two folds. One is to make it available on all platforms and the other is to enhance performance. I think you may all have noticed the differences.

Desktop Applications can be web-enabled by using CITRIX and similar third-party applications, which will give benefit the both Web and Desktop worlds. The license fee for this implementation will be between USD 60 to 100 per concurrent user.

Posted on 6,861 Comments

FireDAC Memory Table

FireDAC FDMemTable is an in-memory dataset component that allows the storage of data in table format in local memory. It does not require any database connection so it is very handy on many occasions.

In order to use it, just the fields have to be defined and ready for actions like add, edit, delete records. It can be used for storing data from external files like csv for temporary manipulations.

A. Create fields in memory table

Var
FDMemTable1 : TFDMemTable;

begin;
with FDMemTable1.FieldDefs do
begin
Add(‘EmpID’, ftInteger, 0, True);
Add(‘EmpName’, ftString, 50, False);
end;

FDMemTable1.CreateDataset;
FDMemTable1.Open;
end;

B. Add/Edit data in memory table

with FDMemTable1 do
begin
Append;
//Edit;
Fields[0].AsInteger := 1;
Fields[1].AsString := ‘Surendra’;
Post;
end;

C. Deleting data from memory table

FDMemTable1.Delete;

D. Delete all records from memory table

FDMemTable1.EmptyDataset;

E. Sorting Data
Use Index for sorting. So we can use property Indexes, IndexDefs or IndexFieldNames.

FDMemTable1.IndexFieldNames := ‘AcctID ASC’;

Or

FDMemTable1.IndexDefs.Add(‘Index1’, ‘AcctID’, [ixPrimary]);
FDMemTable1.IndexName := ‘Index1’;

Or

F. Find Data
Just like in other dataset use Locate, Lookup and Find methods to find a specific record.

Locate
FDMemTable1.Locate(‘AcctID’, 1, []);

Or

FDMemTable1.Locate(‘Name’, ’Surendra’, [loCaseInsensitive]);

Lookup

var
sName: string;
sName := FDMemTable1.Lookup(‘AcctID’, 1, ‘Name’);

FindKey
Findkey will work if only any Index is applied

FDMemTable1.FindKey([1]);
FDMemTable1.FindFirst;
FDMemTable1.FindLast;
FDMemTable1.FindNext;
FDMemTable1.FindPrev;

G. Filtering Data

FDMemTable1.Filtered := False;
FDMemTable1.Filter := ‘AcctID=1’;
FDMemTable1.Filtered := True;

H. Copy data from one FDMemTable to another

The most simple way to copy the structure and data from a TdataSet or a TFDMemTable to another TFDMemTable is to use the CopyDataSet method:

FDMemTable1.CopyDataSet(SourceFDMemTable2, [coStructure, coRestart, coAppend]);
FDMemTable1.CopyDataSet(SourceDataset2, [coStructure, coRestart, coAppend]);

Data property

// UniDirectional must be false

FDQuery1.FetchOptions.Undirectional := False;
FDQuery1.Sql.Text := ‘select * from Account’;
FDQuery1.Open;
FDMemTable1.Data := FDQuery1.Data;
FDMemTable1.First;
while not FDMemTable1.Eof do
begin
FDMemTable1.Edit;
// other codes
FDMemTable1.Post;
FDMemTable1.Next;
end;

I. Difference between CopyDataset and Data property

  1. CopyDataSet can copy from a non-FireDAC dataset but Data property allows you to copy data only from a FireDAC dataset.
  2. CopyDataSet works through TDataSet firing appropriate events but Data property works through no events are fired.
  3. CopyDataSet copies only current field values but Data property copies all record field versions and preserves the row state (inserted, deleted, updated, or unchanged).

Assigning values to Data is much faster than CopyDataSet.

Optimize the performance of TFDMemTable
Set the following properties LogChanges, FetchOptions, ResourceOptions, and UpdateOptions, DisableControls.

FDMemTable1.LogChanges := False;
FDMemTable1.ResourceOptions.SilentMode := True;
FDMemTable1.UpdateOptions.LockMode := lmNone;
FDMemTable1.UpdateOptions.LockPoint := lpDeferred;
FDMemTable1.UpdateOptions.FetchGeneratorsPoint := gpImmediate;
FDMemTable1.DisableControls;
FDMemTable1.BeginBatch;
try
for i := 1 to 100 do begin
FDMemTable1.Append;
//other codes
FDMemTable1.Post;
end;
finally
FDMemTable1.EndBatch;
FDMemTable1.EnableControls;
end;

Posted on 11,433 Comments

When do I write the console application?

Server-side automation

Console applications are executed from the command line without any user interfaces. Therefore, console applications are a very effective way of performing tasks on a regular basis without any user interaction. I write it when there are requirements for such a type of automation.

Automation not only helps to speed up the workflow but also helps to avoid errors. Manually executed tasks are always risky. You don’t know who does them and if the person is not experienced with these tasks, it can lead to errors. By automating tasks, you save yourself from making that type of mistake.

Fast Coding

Creating a console application is much faster than creating an application including a user interface. There are a lot of questions regarding user interface, color combination, user experiences, etc. for an application with a user interface. A console application does not need to consider such requirements. Just to concentrate on functional requirements.

Robustness

Once created, a console application does not have to be changed unless the requirements change. Console applications do not need to change with every new shiny framework, or tool that’s trending right now.

Conclusion

I write console applications when certain functions to be performed on a regular basis which can be executed without user interactions. It makes it flexible, easy to modify and add functionality when needed.

Posted on 1,998 Comments

Memory Leak and Solution

What is Memory Leak

memory leak is a kind of resource consumption that occurs when the code does not manage memory allocations while creating the objects. So in order to manage it, the memory used by the object created should be released when not needed. For example, if you call a function or procedure where the object is created and not released then it goes on consuming memories due to multiple calls from the calling programme. A memory leak may also happen when an object is stored in memory but cannot be accessed by the running code.

This could be a serious issue when the system or service is used for 24x7x365 without addressing it. If not handled it will slow down the system by consuming all resources and finally hangs the system.

How to solve it

There are several third party tools available but the simple solution solution is to release or free the used components or objects when not needed while exiting the funtion procedure.

Example:

procedure DoSomething;
var sl : TStringList;
begin
  sl := TStringList.create()
  try
    try
      // code that may raise exception
      sl.Add('suren');
      sl.Add('sujan');
    except
      ShowMessage('Error occured !');
    end;
  finally
    // Free all memory used in this block
    sl.free;
  end;
end;

Note that there are two try blocks are used in above code. They are different and serve two different purposes. First try is used to make all objects free and the second try is used to trap the errors.

The finally block will always be executed, even if there is no exception, while the except block is only executed when there is an exception.

The finally block is even executed when you exit the function early using Exit in a try-finally block.

The except block is meant to handle the exception(s), while the finally block is not. The finally block is meant to contain code that should be executed regardless of an exception, i.e. mainly to protect resources. That is why you should do:

s := b.Create;
try
  // Code that may raise an exception.
finally
  s.Free; // Free resource, even if there was an exception.
          // Exception is NOT handled.
end;

and:

try
  // Code that may raise an exception.
except
  // Handle the kind of exceptions you can handle.
end;

combined :

try
  try
    // code that may raise exception
  except
    // Handle Exception;
  end;
finally
    // Free all memory used in this block
end;

Note the finally block is not limited to memory management. It can be used for other actions like restoring/undo/close opened files, close open connections, shut down hardware that was started etc.

Posted on 1,013 Comments

Who am I?

I am trying to find out the answer of this question.

If some one ask me, Who Are You ?

My answers could be one of the following:

A1. I am Surendra Siddhi Bajracharya ( Comment: That is the name given to me from your parent)

A2. I am software developer. (Comment: That is my profession)

A3. I am Director of Mercantile ( Comment: That is the position given to me by Mercantile)

A4. I am Buddhist (Comment: That is the Religion identification given to those who follow Buddhism)

A5. I am father of two kids. ( Comment : that is the relationship given to me)

None of the above answers is correct. Then what is the correct answer?. Let me dissect it.

Let us take an example. We will feel very bad when we lose our job or our belongings. Again the level of feelings depends on the love and attachment to those belongings. Job is not me and belongings, are not me? Then why it is happening so ?, Why it hurts me?. It hurts me because I am attached to it. So I have to detach from it for not to be hurt. This is the illusion created by brain for that object as relationship of attachement.

I have seen that when we repeatedly do the same thing for a long period of time or live with some relationship for a long time, we are attached to it and difficult to detach from it. Immediate detachment from anything will bring difficulties and hard to tolerate. I have experienced that our brain works that way. After a period of time, the effect of that detachment will be less effective. Our brain is configured to work that way. So to find out the answer, we need to train our brain by practising meditation to witness the truth ” Everything is impermanent and subject to changes without NOTICE”. Once we know this truth, we will be happy as we do not fear detachment

Posted on 2,751 Comments

System Error 5

While installing Windows Services, you may get “System error 5 has occurred”  Error or “EOSError Code: 5 Access Denied” Error. This error was due to insufficient permission to run command. The easiest way to run Command Prompt as an administrator is to find the “command prompt” in Search and once you find it, right-click on the “Command Prompt” and then Choose “Run as administrator” to run it with administrative privileges.

Another option is to run in command prompt as below:

C:\net user administrator /active:yes

It is also possible to run netplwiz to solve this error

Posted on 32 Comments

Delphi Service Application

Windows Service Application

What is Windows Service?

Microsoft Windows service is an application software which runs in the background. Service applications accept requests from client applications, process those requests, and return information to the client applications. As it runs in the background, it does not require user input interaction. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface. The service can have multiple methods to execute at the background level. So it can be used for different background processing like checking system update, processing routines, validations of data etc.

Why do we need it?

Windows services are needed when an application needs to continuously run without user interaction. Services runs until it is stopped or the computer is turned off. When the system needs to respond 24/7/365, then Windows Services Applications are used. When it is running, it is capable of getting requests from clients and return the response.

What are its limitations?

Service Application does not allow to use visual components. Only non-visual components are allowed in service applications. Besides that every processing in the background can be achieved.

When there is a requirement of huge data communication between client and server, DataSnap will be the right choice as it is more flexible and can be deployed as Windows services and Web Services usiing IIS, Apachy and even standalone server.

Posted on 10,487 Comments

How to Create a Console Application that Accepts Command-Line parameters in Delphi

Steps: In the Delphi IDE, choose File/New/Console Application. Then write

program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;

begin
// Following code you have to write

if ParamCount = 0 then
begin
Writeln(‘No parameters passed.’);
end;
if ParamCount = 1 then
begin
Writeln(‘One Parameter passed!’);
Writeln(ParamStr(1));
end;
if ParamCount = 2 then

begin
Writeln(‘Two Parameters passed!’);
Writeln(ParamStr(1));
Writeln(ParamStr(2));
end;
if ParamCount > 2 then
Writeln(‘More than Two Parameters passed!’);
end.

Compile.

Run CMD and go to directory where you saved the project

In Command Prompt

c:\TestConsole\Project1 “hello world”

One parameter passed

hello world

c:\TestConsole\Project1 “hello” “world”

Two Parameter passed

hello

world

Posted on 42 Comments

I am in love with Delphi

At the very beginning, when I entered into IT field in 1981, I started learning COBOL and C programming languages. Then after a few years, I learned dBase III and started writing codes to develop business application software. For a decade I developed software in dBase and also used CLIPPER compile to create executable files. For some companies, I used Paradox database as well. Those DOS programs worked great and customers were all happy using my software. The software I developed POS, Accounting, Tour and Travel Handling, Movie Theatre Ticketing System and many more.

In 95, I started converting my existing CLIPPER software to CA Visual Object for Window Operating System but I was not happy with Visual Object. So I switched to Delphi and started the migration. Since then I never looked back. I used Delphi for all my projects as it the best tool for database software development.

I love delphi because:

  1. Most powerful native compiler
  2. Delphi created programs executes very fast
  3. Component based and many third party components are available to make programmers life easy.
  4. Delphi is know as the best programming tool in all aspect. It was created by Anders Hejlsberg. Later Microsoft hired him to create C# because Delphi is the best.
  5. Productivity of the programmers 5 times high
  6. few programmers can product very larg software
  7. Delphi from the very begining has concept of low-code
  8. Ease of code maintenance due to readabilty
  9. One language for all cross-plateform applications. Windows, iOS, MAC, Linux, Android
Posted on 21 Comments

Life is Unfair

Yes, it is true. Don’t expect life to be fair always.

Suppose you are a good person and you do all good stuff, always nice to all, do your work best etc., it does not mean that you will get all fair in life. Life has its own rule and works on a complicate algorithm and it is not same to everyone. You may think you deserve it, but it does not mean that you get it. We can see this unfair everywhere, whether it is in promotion in office, award function, recognization etc.

Everything in this world is impermanent and subject to change. So don’t panic. Instead, move ahead with more power. If you stop you are gone if you move forward you will get it and your day will come when you will be appreciated and honoured.

Learned to live with unfairness.