Monday, June 8, 2015

Google Protobuf: Introduction

Google Protobuf has simplified a historically cumbersome process of sending messages from one component of an application to another.

They have made the communication, data storage, platform independent. An object serialized in Java can easily be de-serialized in C++.

Google protobuf aids in managing structured data in a better way. Definitions are easily extensible and simple to use.

.Proto File
Data Definition is created once in a simple format. It is stored as .proto file. These proto files are much simpler to write and manage than xml files that we have been using till now.

This file is compiled and we get generated source code in whatever programming language we want. We can then populate the object using Builder/Getter-Setter, Serialize it and send/store. Later de-serialize it in a different language (or same) and retrieve the information.

 An example below



This .proto can now be compiled and language specific Data Access Classes are created. These classes have auto-generated getter/setter functions for members.

We can declare package name at the top of protofiles, dependency on other protofiles, just like any Java code. Compiler takes care of it all.

More about Google Protobuf below;

No comments:

Post a Comment