Pages

Friday, 31 January 2014

Frequently Asked Basic PostgreSQL Interview Questions and Answers

Frequently Asked Basic PostgreSQL Interview Questions and Answers

PostgreSQL is the widely used open source database. If you are preparing for PostgreSQL interview, following list of basic PostgreSQL interview questions and answers might help you in your interview preparation. Following PostgreSQL interview questions and answers cover PostgreSQL basic concepts like feature and advantages of PostgreSQL, key difference between MySQL and PostgreSQL, basic PostgreSQL database administration commands and tools, general PostgreSQL database concepts like Stored Procedures, Functions, Triggers, Cursor, Index, Joins, Subqueries etc. 

1. What is PostgreSQL? What do you know about PostgreSQL?

PostgreSQL, often simply "Postgres", is an open-source object-relational database management system (ORDBMS) with an emphasis on extensibility and standards-compliance. It is released under the PostgreSQL License, a free/open source software license, similar to the MIT License. PostgreSQL is developed by the PostgreSQL Global Development Group, consisting of a handful of volunteers employed and supervised by companies such as Red Hat and EnterpriseDB.

Read more about PostgreSQL on Wikipedia and PostgreSQL official website

2. What are the various features and advantages of PostgreSQL?

This is very basic question and you should be updated on this. You should know why are you using PostgreSQL in your project, what features and advantages does PostgreSQL provide.

Visit official PostgreSQL website to learn more features and advantages of PostgreSQL

3. What are the key differences between MySQL and PostgreSQL? Which Open Source Database to Choose? Which one is best? 

MySQL and PostgreSQL are both free and open source powerful and full-featured databases. You should be able to compare these two databases. Here is the complete article on this.

4. What are the various PostgreSQL database administration commands and tools?

You should know basic PostgreSQL database administration commands like creating users in PostgreSQL, setting up user credentials in PostgreSQL, change / update PostgreSQL user password, check whether PostgreSQL is up and running, commands to create, delete, drop, start, stop, restart, backup, restore PostgreSQL database, getting the list of all databases in PostgreSQL, finding out what version of PostgreSQL is running, PostgreSQL help and history commands, commands to get the list of all the tables in a PostgreSQL database, commands to turn on timing and checking how much time a query takes to execute, commands to see the list of available functions in PostgreSQL etc. Here is the complete article on this topic.

You should also know some of the PostgreSQL administration tools. You can visit Wiki and Stackoverflow to get to know various PostgreSQL administration tools.

5. PostgreSQL database general concepts

Beside all this you should be well aware of datatypes in PostgreSQL, DDL, DML, DCL commands used in PostgreSQL. You should have good knowledge of Indexes, Joins, Subqueries, Stored Procedures, Functions, Triggers, Cursors etc.

I hope you will get benefited by these basic PostgreSQL interview questions and answers.

16 PostgreSQL Database Administration Commands

16 PostgreSQL Database Administration Commands

Following are basic PostgreSQL database administration commands which each PostgreSQL database administrator should know. These PostgreSQL database administration commands include creating users in PostgreSQL, setting up user credentials in PostgreSQL, change / update PostgreSQL user password, check whether PostgreSQL is up and running, commands to create, delete, drop, start, stop, restart, backup, restore PostgreSQL database, getting the list of all databases in PostgreSQL, finding out what version of PostgreSQL is running, PostgreSQL help and history commands, commands to get the list of all the tables in a PostgreSQL database, commands to turn on timing and checking how much time a query takes to execute, commands to see the list of available functions in PostgreSQL etc. Lets have a look on following PostgreSQL Database Administration Commands.

1. How to change PostgreSQL root user password?

$ /usr/local/pgsql/bin/psql postgres postgres
Password: (oldpassword)
# ALTER USER postgres WITH PASSWORD 'tmppassword';

$ /usr/local/pgsql/bin/psql postgres postgres
Password: (tmppassword)

Changing the password for a normal postgres user is similar as changing the password of the root user. Root user can change the password of any user, and the normal users can only change their passwords as Unix way of doing.

# ALTER USER username WITH PASSWORD 'tmppassword';

2. How to setup PostgreSQL SysV startup script?

$ su - root

# tar xvfz postgresql-8.3.7.tar.gz

# cd postgresql-8.3.7

# cp contrib/start-scripts/linux /etc/rc.d/init.d/postgresql

# chmod a+x /etc/rc.d/init.d/postgresql

3. How to check whether PostgreSQL server is up and running?

$ /etc/init.d/postgresql status
Password:
pg_ctl: server is running (PID: 6171)
/usr/local/pgsql/bin/postgres "-D" "/usr/local/pgsql/data"
[Note: The status above indicates the server is up and running]

$ /etc/init.d/postgresql status
Password:
pg_ctl: no server running
[Note: The status above indicates the server is down]

4. How to start, stop and restart PostgreSQL database?

# service postgresql stop
Stopping PostgreSQL: server stopped
ok

# service postgresql start
Starting PostgreSQL: ok

# service postgresql restart
Restarting PostgreSQL: server stopped
ok

5. How do I find out what version of PostgreSQL I am running?

$ /usr/local/pgsql/bin/psql test
Welcome to psql 8.3.7, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

test=# select version();
version
----------------------------------------------------------------------------------------------------
PostgreSQL 8.3.7 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)
(1 row)

test=#

6. How to create a PostgreSQL user?

There are two methods in which you can create user.

Method 1: Creating the user in the PSQL prompt, with CREATE USER command.

# CREATE USER ramesh WITH password 'tmppassword';
CREATE ROLE

Method 2: Creating the user in the shell prompt, with createuser command.

$ /usr/local/pgsql/bin/createuser sathiya
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
CREATE ROLE

7. How to create a PostgreSQL Database?

There are two metods in which you can create two databases.

Method 1: Creating the database in the PSQL prompt, with createuser command.

# CREATE DATABASE mydb WITH OWNER ramesh;
CREATE DATABASE
Method 2: Creating the database in the shell prompt, with createdb command.

$ /usr/local/pgsql/bin/createdb mydb -O ramesh
CREATE DATABASE
* -O owner name is the option in the command line.

8. How do I get a list of databases in a Postgresql database?

# \l  [Note: This is backslash followed by lower-case L]
List of databases
Name | Owner | Encoding
----------+----------+----------
backup | postgres | UTF8
mydb | ramesh | UTF8
postgres | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8

9. How to Delete/Drop an existing PostgreSQL database?

# \l
List of databases
Name | Owner | Encoding
----------+----------+----------
backup | postgres | UTF8
mydb | ramesh | UTF8
postgres | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8

# DROP DATABASE mydb;
DROP DATABASE

10. Getting help on postgreSQL commands

\? will show PSQL command prompt help. \h CREATE will shows help about all the commands that starts with CREATE, when you want something specific such as help for creating index, then you need to give CREATE INDEX.

# \?

# \h CREATE

# \h CREATE INDEX

11. How do I get a list of all the tables in a Postgresql database?

# \d
On an empty database, you’ll get “No relations found.” message for the above command.

12. How to turn on timing, and checking how much time a query takes to execute?

# \timing — After this if you execute a query it will show how much time it took for doing it.

# \timing
Timing is on.

# SELECT * from pg_catalog.pg_attribute ;
Time: 9.583 ms

13. How To Backup and Restore PostgreSQL Database and Table?

We discussed earlier how to backup and restore postgres database and tables using pg_dump and psql utility.

14. How to see the list of available functions in PostgreSQL?

To get to know more about the functions, say \df+

# \df

# \df+

15. How to edit PostgreSQL queries in your favorite editor?

# \e
\e will open the editor, where you can edit the queries and save it. By doing so the query will get executed.

16. Where can I find the PostgreSQL history file?

Similar to the Linux ~/.bash_history file, postgreSQL stores all the sql command that was executed in a history filed called ~/.psql_history as shown below.

$ cat ~/.psql_history
alter user postgres with password 'tmppassword';
\h alter user
select version();
create user ramesh with password 'tmppassword';
\timing
select * from pg_catalog.pg_attribute;

Thursday, 30 January 2014

How to load Help File (.chm file) in your Delphi Project using HTMLHelpViewer?

How to load Help File (.chm file) in your Delphi Project using HTMLHelpViewer?

Having the help option in your Delphi project is very common in which you want to load the chm file. If you want to create such a functionality in your project, here is the solution. It is very simple in Delphi. Following are the steps which you require to implement help functionality in your Delphi Project.

1. Create a valid chm file and place it in a directory where your exe is placed.

2. Include a unit "HTMLHelpViewer" under your uses section. HTMLHelpViewer is needed to register a viewer for HTML help.

3. On the click of help menu button, put the following code:

procedure TMyForm.ExecuteHelp(Sender: TObject);
begin
  If Application.HelpFile <> '' then
    Application.HelpCommand(HELP_CONTEXT,100) 
  else
    Messagedlg('Cannot load help file');
end;

Application.HelpFile fetches the exact address of your chm file. Application.HelpCommand(HELP_CONTEXT,100) loads your chm file in your Delphi project.

I think this simple tutorial will be useful to you for creating help file in your Delphi project.

Monday, 27 January 2014

Calling Conventions in Delphi: safecall vs stdcall vs cdecl

Calling Conventions in Delphi: safecall vs stdcall vs cdecl

Calling conventions in Delphi determine the order in which parameters are passed to the routine. Calling conventions also affect the removal of parameters from the stack, the use of registers for passing parameters, and error and exception handling. 

Calling Conventions in Delphi

One of the most common operations in the processing of code is calling a subroutine that carries out a given task. In order to do that, the main code needs to hand over control to the subroutine, allow the subroutine to execute, and then return to where it left the main execution path. This process requires agreement between the caller and the callee about how to pass information to the subroutine, how to return results where applicable and who is responsible for the memory allocation and cleanup. Various conventions exist to deal with invoking subroutines, commonly known as calling conventions.

Calling conventions in Delphi define a number of different aspects of subroutine invokation:

1. Where parameters are located: in registers or on the stack
2. In which order parameters are passed: right-to-left or left-to-right
3. Who is responsible for cleaning up the parameters afterwards, the caller or the callee

Various calling conventions in Delphi are register, pascal, cdecl, stdcall, and safecall. The default calling convention is register.

The register and pascal conventions pass parameters from left to right; that is, the leftmost parameter is evaluated and passed first and the rightmost parameter is evaluated and passed last. The cdecl, stdcall, and safecall conventions pass parameters from right to left.

For all conventions except cdecl, the procedure or function removes parameters from the stack upon returning. With the cdecl convention, the caller removes parameters from the stack when the call returns.

The register convention uses up to three CPU registers to pass parameters, while the other conventions pass all parameters on the stack.

The safecall convention implements COM error and exception handling.

The default register convention is the most efficient, since it usually avoids creation of a stack frame (Access methods for published properties must use register). The cdecl convention is useful when you call functions from DLLs written in C or C++, while stdcall and safecall are used for Windows API calls. The safecall convention must be used for declaring dual-interface methods. The pascal convention is maintained for backward compatibility. 

Difference between Safecall and Stdcall calling conventions in Delphi

In Delphi, the safecall calling convention encapsulates COM (Component Object Model) error handling, thus exceptions aren't leaked out to the caller, but are reported in the HRESULT return value, as required by COM/OLE. When calling a safecall function from Delphi code, Delphi also automatically checks the returned HRESULT and raises an exception if necessary.

Safecall implements exception 'firewalls'; especially on Win32, this implements interprocess COM error notification. It would otherwise be identical to stdcall (the other calling convention used with the win api)

The safecall calling convention is the same as the stdcall calling convention, except that exceptions are passed back to the caller in EAX as a HResult, while the function result is passed by reference on the stack as though it were a final "out" parameter. When calling a Delphi function from Delphi this calling convention will appear just like any other calling convention, because although exceptions are passed back in EAX, they are automatically converted back to proper exceptions by the caller. When using COM objects created in other languages, the HResults will be automatically raised as exceptions, and the result for Get functions is in the result rather than a parameter. When creating COM objects in Delphi with safecall, there is no need to worry about HResults, as exceptions can be raised as normal but will be seen as HResults in other languages.

function function_name(a: DWORD): DWORD; safecall;

Returns a result and raises exceptions like a normal Delphi function, but it passes values and exceptions as though it was:

function function_name(a: DWORD; out Result: DWORD): HResult; stdcall;

SafeCall function mapping determines which functions are declared as safecall when declarations specified in Delphi are converted to Restricted Interface Definition Language (RIDL) in the generated type library. Safecall functions automatically implement COM conventions for errors and exception handling, converting HRESULT error codes into exceptions. If you are entering function declarations in RIDL, you must explicitly specify the calling convention as safecall or stdcall.

Difference between stdcall and cdecl calling convention

cdecl and __stdcall just tells the compiler whether the called function or the calling function cleans up the stack. In __stdcall calling convention, the called function cleans up the stack when it is about to return. So if it is called in a bunch of different places, all of those calls do not need to extra code to clean up the stack after the function call.

In __cdecl calling convention, it is the caller function that is responsible for cleaning the stack, so every function call must also need to include extra code to clean up the stack after the function call.

Default Calling Convention for C programmes

The __cdecl is the default calling convention for C programs. In this calling convention, the stack is cleaned up by the caller. The __cdecl calling convention creates larger executables than __stdcall, because it requires each function call to include stack cleanup code.

Default Calling Convention for Windows Programmes

The __stdcall calling convention is used to call Win32 API functions. The callee cleans the stack. Functions that use this calling convention require a function prototype.

return-type __stdcall function-name[(argument-list)]

Saturday, 25 January 2014

Devexpress vs Telerik vs Infragistics: Which one to choose and why?

Devexpress vs Telerik vs Infragistics: Which one to choose and why?

Devexpress, Telerik and Infragistics are the great third party tools for you for both your windows and web application. These third party tools mainly support .NET technologies like WinForms, Silverlight, ASP.NET and WPF. Devexpress also supports windows application built in Delphi programming language and I am currenty working on it. Also I have heard some other third party tools like ComponentOne, SyncFusion and Januscontrols but never worked upon them. Which one is good, which one to choose and why? Although this is difficult and time consuming task, but let's try to solve the confusion.

Why do we require these third party tools for our application?

These all thrid party tools are mainly used for improving the user interface which standard controls cannot provide. Devexpress, Telerik and Infragistics third party tools provide a lot of exciting features and components which you require like attractive dashboards, advanced reporting tools, sorting, searching, grouping, paging, filtering, databinding, drag and drop features, intelligent editors, smart control panels, importing and exporting features, attractive ribbon bars, complex tree views and graphs, cool transition controls, rich textboxes, navigation contorls, charting controls, complex themes and much more...

Devexpress vs Telerik vs Infragistics: Which one to choose and why?

Which tool is best? This is very hard to say. This question seems philosophical to me. There's no one answer.

Devexpress, Telerik and Infragistics have their own strong and weak points. Each and every tool has some learning curve to understand its way of doing the things. These all tools provide excellent performance and great convenience to the user. 

It is upto you and your needs to choose one of these. Following are some humble suggestions which you can consider before choosing one of these tools for your windows or web application.

1. What is your requirement?

What is the nature of your application and what functionalities do you want to put in? This should be the first questions striking in your mind before choosing any thrid party tool for your UI. Once you finalized your requirement, then move to these contorls and read their documentation, features list, online demos, try trial versions to implement your functionality. If the tool is giving you your desired functionality, consider it.

2. Your familiarity with tool

A good choice, nevertheless is to choose one you know. I would start by expressing my opinion that the best tool set is the one with which you gain your greatest familiarity. I think the market demonstrates that there is a sufficient percentage of buyers to support all these three tools. I would also conjecture that the longer you work in any one, the more you will like it. 

My observation is that each library comes with its own set of presuppositions: about structure, nomenclature, interface and class design and inheritance; about consistency and your mental model of the controls and events; about many things. 

Some of these presuppositions blend easily with the way some people think. Others blend better with other brain architecture. It doesn't mean one is better or worse. It means one is different than the other. You have to find the one that works for the way you think and program. Otherwise you will be twisting on a right-hand nut with a left-hand wrench.

3. Which tool your co-workers and other teams of your company are using?

You should also investigate with other teams in your company if they are using any of these tools. If yes, learn from their experience. 

4. Support and Documentation

Evaluate each tool in terms of their support and documentation. Go with tool which provide solid support, documentation, sample examples, tutorials, example codes and demonstrations. All the component libraries should be well-represented and documented. When you will use a third party software or tool, you will need much help from those people. The tool vendor should have good forum.

5. Cross browser compliant

If you are looking for Devexpress, Telerik and Infragistics for you web application, must ensure that all the features which you need from these third party tools run same on all the browsers. 

6. Cost and Licensing 

Cost should be reasonable and licensing should be simple. 

Conclusion

To be fair, all grid components will do great if you're on the standard track. As soon as you'll have something to implement that is not a general purpose usage it will get harder. This is true for all third party controls.

Compare demos and trial versions based on your needs. I would encourage you to evaluate the controls on your own to see which control will best meet your needs. That's the best suggestion I can suggest.

Friday, 17 January 2014

MongoDB vs Cassandra: Difference and Similarities between MongoDB and Cassandra

MongoDB vs Cassandra: Difference and Similarities between MongoDB and Cassandra

MongoDB and Cassandra have occupied a very big market of NoSQL Schema-Free databases. So, before going to choose any one of them, it is logical to compare basic features of both MongoDB and Cassandra. MongoDB and Cassandra both are fully-featured NoSQL databases and choosing one of them heavily depends upon your application requirements. There are a lot of similarities and differences between MongoDB and Cassandra. Following is the basic comparison of MongoDB and Cassandra in terms of data storage model, usage etc.

Differences between MongoDB and Cassandra

1. MongoDB has a document-oriented data model while Cassandra has column-oriented data model and storage type. 

MongoDB acts much like a relational database. Its data model consists of a database at the top level, then collections which are like tables in MySQL (for example) and then documents which are contained within the collection, like rows in MySQL. Each document has a field and a value where this is similar to columns and values in MySQL. Fields can be simple key / value e.g. { 'name': 'David Mytton' } but they can also contain other documents e.g. { 'name': { 'first' : David, 'last' : 'Mytton' } }.

In Cassandra documents are known as “columns” which are really just a single key and value. e.g. { 'key': 'name', 'value': 'David Mytton' }. There’s also a timestamp field which is for internal replication and consistency. The value can be a single value but can also contain another “column”. These columns then exist within column families which order data based on a specific value in the columns, referenced by a key. At the top level there is a keyspace, which is similar to the MongoDB database.

2. MongoDB is developed by MongoDB, Inc while Cassandra is a product of Apache Software Foundation. The original authors of MongoDB are core contributors to the code and work for 10gen (indeed, 10gen was founded specifically to support MongoDB and the CEO and CTO are the original creators). In contrast, Cassandra was created by 2 engineers from Facebook and is incubated by the Apache Foundation. MongoDB was initially released in 2009 while Cassandra was released in 2008.

3. MongoDB is implemented in C++ while Cassandra is implemented in Java.

4. MongoDB supports Linux, OS X, Solaris and Windows server operating systems while Cassandra supports BSD, Linux, OS X and Windows server operating systems.

5. MongoDB supports more programming languages than Cassandra. MongoDB supports Actionscript, C, C#, C++, Clojure, ColdFusion, D, Dart, Delphi, Erlang, Go, Groovy, Haskell, Java, JavaScript, Lisp, Lua, MatLab, Perl, PHP, PowerShell, Prolog, Python, R, Ruby, Scala and Smalltalk. Cassandra supports C#, C++, Clojure, Erlang, Go, Haskell, Java, JavaScript, Perl, PHP, Python, Ruby and Scala. 

6. Handling of indexes is different in MongoDB and Cassandra

MongoDB indexes work very similar to relational databases. You create single or compound indexes on the collection level and every document inserted into that collection has those fields indexed. Querying by index is extremely fast so long as you have all your indexes in memory.

Prior to Cassandra 0.7 it was essentially a key/value store so if you want to query by the contents of a key (i.e the value) then you need to create a separate column which references the other columns i.e. you create your own indexes. This changed in Cassandra 0.7 which allowed secondary indexes on column values, but only through the column families mechanism. Cassandra requires a lot more meta data for indexes and requires secondary indexes if you want to do range queries.

7. Handling of replication is different in MongoDB and Cassandra

In MongoDB replication is achieved through replica sets. This is an enhanced master/slave model where you have a set of nodes where one is the master. Data is replicated to all nodes so that if the master fails, another member will take over. There are configuration options to determine which nodes have priority and you can set options like sync delay to have nodes lag behind (for disaster recovery, for example).

Writes in MongoDB are “unsafe” by default; data isn’t written right away by default so it’s possible that a write operation could return success but be lost if the server fails before the data is flushed to disk. This is how Mongo attains high performance. If you need increased durability then you can specify a safe write which will guarantee the data is written to disk before returning. Further, you can require that the data also be successfully written to n replication slaves.

MongoDB drivers also support the ability to read from slaves. This can be done on a connection, database, collection or even query level and the drivers handle sending the right queries to the right slaves, but there is no guarantee of consistency (unless you are using the option to write to all slaves before returning). In contrast Cassandra queries go to every node and the most up to date column is returned (based on the timestamp value).

Cassandra has much more advanced support for replication by being aware of the network topology. The server can be set to use a specific consistency level to ensure that queries are replicated locally, or to remote data centres. This means you can let Cassandra handle redundancy across nodes where it is aware of which rack and data centre those nodes are on. Cassandra can also monitor nodes and route queries away from “slow” responding nodes.

The only disadvantage with Cassandra is that these settings are done on a node level with configuration files whereas MongoDB allows very granular ad-hoc control down the query level through driver options which can be called in code at run time.

8. MongoDB provides a custom map/reduce implementation while Cassandra provides native Hadoop support, including for Hive (a SQL data warehouse built on Hadoop map/reduce) and Pig (a Hadoop-specific analysis language that many think is a better fit for map/reduce workloads than SQL).

9. MongoDB supports server-side scripting while Cassandra does not.

10. Major users of MongoDB are Craigslist, Foursquare, Shutterfly, Intuit while Facebook, Twitter and Digg heavily use Cassandra.

11. MongoDB is commercial while Cassandra is free.

Similarities between MongoDB and Cassandra

1. Both MongoDB(AGPL) and Cassandra(Apache 2.0 license) are open-source databases.
2. Both MongoDB and Cassandra are NoSQL schema-free databases.
3. Both MongoDB and Cassandra support Sharding.
4. Both MongoDB and Cassandra support concurrency. Concurrency is supported by using Locks in MongoDB while concurrency in Cassandra is achieved by MVCC.
5. Both MongoDB and Cassandra support Eventual and Immediate Consistency. 
6. None supports Foreign keys, Transaction concepts, Triggers etc.

24 Frequently Asked Basic SOA Interview Questions and Answers

24 Frequently Asked Basic SOA Interview Questions and Answers

SOA stands for Service Oriented Architecture. If you are preparing for SOA interview, the following SOA interview questions and answers can be very useful to you. Basically, these SOA interview questions and answers cover basic concepts of SOA like services in SOA, characteristics and principles of services in SOA, loose coupling of services, contract, address and bindings in SOA, main benefits of SOA to the business and IT, difference between services and components in SOA, requirement of SOA to the business, pitfalls of SOA etc. Let's have a look:

1. What is a Service in SOA?

In the real world, a service is what we pay for and we get the intended service. 

Example 1 (from Real World): You go to a restaurant and order food. Your order first goes to the counter and then it goes to the kitchen where the food is prepared and finally the waiter serves the food.

So in order to order an item from a restaurant you need three logical departments / services to work together (counter, kitchen, and waiter).

In the same manner in software world, these services are termed as business services. 

Example 2 (from Software World): You go to Amazon to order a book. Different services like payment gateway, stock system, and delivery system come together to achieve your task. 

All the services are self contained and logical. They are like black boxes. In short we do not need to understand the internal details of how the business service works. For the external world it’s just a black box which takes messages and serves accordingly. For instance the ‘payment gateway’ business service takes the message ‘check credit’ and gives out output: does the customer have credit or not. For the ‘order system’ business service ‘payment gateway’ service is a black box.

2. What are the main characteristics of services in SOA?

Following are the main characteristics of services in SOA:

A) SOA components are loosely coupled. When we say loosely coupled that means every service is self contained and exists alone logically. For instance we take the ‘payment gateway’ service and attach it to a different system.

B) SOA services are black boxes. In SOA, services hide there inner complexities. They only interact using messages and send services depending on those messages. By visualizing services as black boxes, services become more loosely coupled.

C) SOA service should be self defined: SOA services should be able to define themselves.

D) SOA services are maintained in a listing: SOA services are maintained in a central repository. Applications can search the services in the central repository and use them accordingly.

E) SOA services can be orchestrated and linked to achieve a particular functionality: SOA services can be used/orchestrated in a plug and play manner. For instance, the figure ‘Orchestration’ shows two services ‘Security service’ and ‘Order processing service’. You can achieve two types of orchestrations from it: one you can check the user first and then process the order, or vice-versa. Yes, you guessed right, using SOA we can manage a workflow between services in a loosely coupled fashion.

3. What is SOA?

SOA stands for Service Oriented Architecture. SOA is an architecture for building business applications using loosely coupled services which act like black boxes and can be orchestrated to achieve a specific functionality by linking together.

4. What are Contract, Address, and Bindings?

These three terminologies on which SOA service stands. Every service must expose one or more ends by which the service can be available to the client. End consists of three important things where, what and how:-

Contract is an agreement between two or more parties. It defines the protocol how client should communicate with your service. Technically, it describes parameters and return values for a method.

An Address indicates where we can find this service. Address is a URL, which points to the location of the service.

Bindings determine how this end can be accessed. It determines how communications is done. For instance, you expose your service, which can be accessed using SOAP over HTTP or BINARY over TCP. So for each of these communications medium two bindings will be created.

5. Are web-services SOA?

SOA is a thinking, it’s an architectural concept, and web service is one of the technical approaches to complete it. Web services are the preferred standards to achieve SOA.

In SOA we need services to be loosely coupled. A web service communicates using the SOAP protocol which is XML based, which is very loosely coupled. It answers the what part of the service.

SOA services should be able to describe themselves. WSDL describes how we can access the service.

SOA services are located in a directory. UDDI describes where we can get the web service. This is nothing but the implementation of the SOA registry.

6. What are the main benefits of SOA?

SOA helps create greater alignment between IT and line of business while generating more flexibility - IT flexibility to support greater business flexibility. Your business processes are changing faster and faster and global competition requires the flexibility that SOA can provide.

SOA can help you get better reuse out of your existing IT investments as well as the new services you’re developing today. SOA makes integration of your IT investments easier by making use of well-defined interfaces between services. SOA also provides an architectural model for integrating business partners’, customers’ and suppliers’ services into an enterprise’s business processes. This reduces cost and improves customer satisfaction

7. What is a reusable Service?

It is an autonomous, reusable, discoverable, stateless functionality that has the necessary granularity, and can be part of a composite application or a composite service.

A reusable service should be identified with a business activity described by the service specifications (design-time contract).

A service’s constraints, including security, QoS, SLA, usage policies, may be defined by multiple run-time contracts, multiple interfaces (the WSDL for a SOAP Web Service), and multiple implementations (the code).

A reusable service should be governed at the enterprise level throughout its entire lifecycle, from design-time through run-time. Its reuse should be promoted through a prescriptive process, and that reuse should be measured.

8. Talking about Service identification, which approach between top-down and bottom-up methodologies encourages re-use and maintenance?

Since the top-down approach is business-driven it can be practical to separate the different concerns of business and IT on different plans, providing a common ground in between. So in most situations it the most appropriate if you want to improve reuse and ROI in the medium/long term. 

9. How can you achieve loose coupling in a SOA?

One strategy for achieving loose coupling is to use the service interface (the WSDL for a SOAP Web Service) to limit this dependency, hiding the service implementation from the consumer. Loose coupling can be addressed by encapsulating the service functionalities in a manner that limits the impact of changes to the implementation on the service interface. However, at some point you will need to change the interface and manage versioning without impacting service consumers, in addition to managing multiple security constraints, multiple transports, and other considerations

10. Do you recall any pattern which could be used to leverage loose coupling?

The Mediation pattern, using an enterprise service bus (ESB), will help in achieving this.

Mediation will take loose coupling to the highest level. It will establish independence between consumers and providers on all levels, including message formats, message types (including SOAP, REST, XML, binary) and transport protocols (including HTTP, HTTPS, JMS).

Architecturally speaking this means the separation of concerns between consumers and providers on the transport, message type, and message format levels.

11. The Service of a SOA should be engineered as stateless or stateful?

Service should be stateless. It may have a context within its stateless execution, but it will not have an intermediary state waiting for an event or a call-back. The retention of state-related data must not extend beyond a request/response on a service. This is because state management consumes a lot of resources, and this can affect the scalability and availability that are required for a reusable service.

12. What is composition of a Service?

Composition is the process by which services are combined to produce composite applications or composite services. A composite application consists of the aggregation of services to produce an enterprise portal or enterprise process. A composite service consists of an aggregation of services that produces another reusable service. It’s just like combining electronic components to create a computer motherboard, and then using that motherboard in a computer. Think of the motherboard as a reusable composite service that is a component of the computer, and of the computer as the composite application.

13. How do I integrate my Legacy applications with SOA?

Legacy applications are frequently at the core of your IT environment. With the right skills and tools, you need to identify discrete elements within your legacy applications and “wrap” them in standards-based interfaces and use them as services within your SOA.

14. How does the ESB fits in this picture?

The Enterprise Service Bus is a core element of any SOA. ESBs provide the “any to any” connectivity between services within your own company, and beyond your business to connect to your trading partners. But SOA does not stop at just implementing an ESB. Depending on what your goals are, you may want to use an ESB to connect other services within your SOA such as information services, interaction services and business process management services. Additionally, you will need to consider development services and IT service management services. The SOA reference architecture can help you lay out an SOA environment that meets your needs and priorities. The ESB is part of this reference architecture and provides the backbone of an SOA but it should not be considered an SOA by itself.

15. In SOA do we need to build systems from scratch?

No. If you need to integrate or make an existing system as a business service, you just need to create loosely coupled wrappers which will wrap your custom systems and expose the systems functionality in a generic fashion to the external world.

16. What’s the difference between services and components?

Services are logical grouping of components to achieve business functionality. Components are implementation approaches to make a service. The components can be in JAVA, C#, C++ but the services will be exposed in a general format like Web Services.

17. The concept of SOA is nothing new, however why everyone started to talk about SOA only in the recent years?

Yes, I agree the basic concepts of SOA aren’t new, however some technology technology changes in the last 10 years made service-oriented architecture more practical and applicable to more organizations than it was previously. Among this:

1. Universally-accepted industry standards such as XML, its many variants, and Web-services standards have contributed to the renewed interest in SOA.

2. Data governance frameworks, which are important to a successful SOA implementation, have well test and refined over the years.

3. A variety of enabling technologies and tools (e.g., modeling, development, infrastructure/middleware, management, and testing) have matured.

4. Understanding of business and business strategies has grown, shifting attention from technology to the people, cultural changes, and process that are key business success factors.

18. What is the most important skill you need to adopt SOA? Technical or Cultural?

Surely cultural. SOA does require people to think of business and technology differently. Instead of thinking of technology first (e.g., If we implement this system, what kinds of things can we do with it?), practitioners must first think in terms of business functions, or services (e.g., My company does these business functions, so how can I set up my IT system to do those things for me most efficiently?).It is expected that adoption of SOA will change business IT departments, creating service-oriented (instead of technology-oriented) IT organizations.

19. What are the main obstacles in the way of SOA?

1. Shortage of skills. 
2. Justifying the ROI of SOA projects. 

20. Can I buy an SOA or must I build one?

To move your organization toward greater service orientation, you need to take a balanced approach to building versus buying. To create the infrastructure for an SOA, you'll need the right commercial off-the-shelf software that complements (rather than replaces) your existing IT infrastructure. This is a “buy” statement. On the “build” side, you may also choose to access know-how and hands-on involvement to use these software products effectively and get the most out of them. This infrastructure and the associated tools can help you create the business services that run on your SOA. Again, there is some “building” associated with this. So the real answer is that you need a certain measure of both building and buying.

21. Do I need SOA Governance to get started?

A key aspect of successful SOA implementations is having business involved in the effort from the beginning. One of the values from SOA you can gain is improved Business/IT Alignment. SOA Governance supplies the decision rights, processes, and policies for business and IT to work together. After a service is deployed, there must be management aspects in place to control and monitor the service. You do not need a lot of SOA Governance to get started, but enough to work with the level of Smart SOA you are implementing.

22. What are SOA Entry Points?

To get started quickly with SOA, you need to select an initial project that focuses on a particular business opportunity that can be completed in a reasonably short time frame. The SOA Entry points are project areas that have been shown to provide business value in a timely manner. Each Entry Point provides a key SOA related solution:

People - collaboration improving productivity by giving employees and partners the ability to create a personalized, consolidated way to interact with others.

Process - optimize and deploy processes on the fly and monitor the effectiveness of the altered processes.

Information - improve business insight and reduce risk by using trusted information services delivered in line and in context.

Reuse - newly created and reusable services are the building blocks of SOA. Reuse gives users flexibility through reduced cycle time and elimination of duplicate processes.

Connectivity - although, in the past, connectivity has been a requirement, SOA brings new levels of flexibility to these linkages. The connectivity provided by SOA has distinct value on its own and as a building block for additional SOA initiatives.

23. What are the common pitfalls of SOA?

One of the most common pitfalls is to view SOA as an end, rather than a means to an end. Developers who focus on building an SOA solution rather than solving a specific business problem are more likely to create complex, unmanageable, and unnecessary interconnections between IT resources.

Another common pitfall is to try to solve multiple problems at once, rather than solving small pieces of the problem. Taking a top-down approach—starting with major organization-wide infrastructure investments—often fails either to show results in a relevant time-frame or to offer a compelling return on investment.

24. Is SOA really needed on your opinion?

SOA is not for everyone. While SOA delivers significant benefits and cost savings, SOA does require disciplined enforcement of centralized governance principals to be successful. For some organizations, the cost of developing and enforcing these principals may be higher than the benefits realized, and therefore not a sound initiative.

About the Author

I have more than 10 years of experience in IT industry. Linkedin Profile

I am currently messing up with neural networks in deep learning. I am learning Python, TensorFlow and Keras.

Author: I am an author of a book on deep learning.

Quiz: I run an online quiz on machine learning and deep learning.