Fakhrul Siddiqei
Fakhrul's Terminal

Fakhrul's Terminal

Declarative vs Imperative UI in Android

Declarative vs Imperative UI in Android

Fakhrul Siddiqei's photo
Fakhrul Siddiqei
Β·Mar 24, 2022Β·

2 min read

π—§π—¬π—£π—˜π—¦ 𝗒𝗙 𝗔𝗑𝗗π—₯π—’π—œπ—— π—¨π—œ 𝗔𝗑𝗗 π—ͺ𝗛𝗔𝗧 𝗧𝗒 π—¨π—¦π—˜?

Every application has a UI framework behind it. These frameworks play a huge part in how the applications are created and their performance as well. They also have different ways of operation but can be summarized into two: declarative and imperative.

𝐈𝐦𝐩𝐞𝐫𝐚𝐭𝐒𝐯𝐞 π”πˆ

This is the most common paradigm. It involves having a separate prototype/model of the application’s UI. This design focuses on the how rather than the what. A good example is XML layouts in Android. We design the widgets and components which are then rendered for the user to see and interact with.

πƒπžπœπ₯𝐚𝐫𝐚𝐭𝐒𝐯𝐞 π”πˆ:

This pattern is an emerging trend that allows the developers to design the user interface based on the data received. This on the other hand focuses on the what. This design paradigm makes use of one programming language to create an entire application. Like JetpacCompose, where we use kotlin to write entire application with UI design and core functionality.

π—©π—²π—Ώπ—±π—Άπ—°π˜

You should now get deeper into learning how to use the declarative format as it is more flexible and easier to use. As, day by day XML will be deprecated from google, jetpack compose will get new update's more then XML. so it will be good to start with jetpack compose if possible go along with it with all upcoming project.

Β 
Share this