AngularJS the MVVM way better modular UI Development

AngularJS the MVVM way better modular UI Development

Lot of buzz about Plug and Play and design patterns in the UI development round the clock!
Plug and Play is possible with good architecture and adoption of good design pattern. Most popular are – MVC, MVP and MVVM. Most of us are familiar with MVC (Model-View-Controller), MVP (Model-View-Presentation) and the one picking up now is – MVVM.

MVVM (Model-View-ViewModel) is actually an architectural pattern used in software engineering that originated from Microsoft as a specialization of the Presentation Model design pattern introduced by Martin Fowler. For those who want to understand more on – MVC, MVP, can refer to http://www.codeproject.com/Articles/288928/Differences-between-MVC-and-MVP-for-Beginners and also MVVM included here – http://www.codeproject.com/Articles/66585/Comparison-of-Architecture-presentation-patterns-M.

The above details are all specific to the design pattern. So let’s now understand how we can adopt to this (MVVM) good pattern in UI development, especially, the Hybrid App development projects.

MVVM components include:
1. Model
2. View
3. View Model
Here, the controller of MVC is replaced by a ViewModel and the View Model is a JavaScript function which acts as a model for the view and is responsible for maintaining relationship between view and the model. If we update anything in view, it gets updated in model, change anything in model, it reflects in the view, and it’s called 2-way data binding. MVVM separates business logic from UI using the ViewModel. AngularJs helps in achieving this using plain JavaScript objects. $scope is the important object in AJS (AngularJS), which allows defining both the data and methods that will be available for the view.
Let’s look into the details of MVVM AJS:
Holds application/domain specific data along with actual information what our app needs to deal with. Eg: user name, age, DOB etc. in a form.
Services or Factories can be used to handle Model in AJS.
Services are view- control logic handlers as well. We can call it as a View-Model interface (or a VM Interface), where all the common business logic reside. This helps in easy plug and play of two dependent modules.
View handles the events, behaviour and actual UI representation.
Eg: A visual representation of a Submit button, button click behaviour etc. The behaviour is actually handled by ViewModel. Eg: On click of a submit button, AJAX Post may be performed and data is posted to server etc (handled by ViewModel); and a pop-up message for success or
failure should be shown up (View).
Angular templates (using directives) act as the Views in AJS Hybrid apps.

Holds the presentation logic and interacts with Model on state changes. Example is discussed in the View details above.

AJS Controllers serve this purpose in Hybrid apps. An AJS controller (the ViewModel) should –

• Include the state of the presentation – like which item is selected using radio button, if a switch is turned on/off etc.
• Utilize and process data from Model/Server – fetch DB, make a post / get AJAX request and pre-process data if required, before presenting.
• Be able to communicate with other Controllers via methods/interfaces.

This is all about AJS MVVM insights. 🙂

Please find the detailed tutorials on AJS here for more information:
https://angularjs.org/ (Official AJS site).

• This article is intended to explain the idea of MVVM design pattern using AJS in Hybrid apps. This will not give any in-depth details of neither MVVM nor AJS.
• AJS can be done in MVC as well.
• MVC handled in a better way is also a good candidate that supports Modularity, and Plug and Play. MVVM enforces MVC in a better modular approach.

Shlokas from the Bhagavad Gita

Shlokas from the Bhagavad Gita

1. Gita dhyaanam – Meditation on the Gita

vasudeva sutam devam
kamsa chaanuura mardanam |
devakii paramaa nandam
krishnam vande jagat gurum ||

I salute Lord Krishna, the son of Vasudeva, the one who gives great delight to Devaki, the destroyer of Kamsa and Chaanuura and the teacher of the world.

2. Chapter 4, Verse 8

paritraanaaya sadhuunaam vinaashaaya chadushkritaam |
dharma samsthaapanaarthaaya sambhavaami yuge yuge ||

For the protection of the good, for the destruction of the evil and for the establishment of dharma (righteousness), I (the Lord) am born from age to age.

3. Chapter 2, Verse 62

dhyaayato vishayaanh pumsah sangasteshhupajaayate |
sangaath samjaayate kaamah kaamaath krodho abhijaayate ||

When a person dwells longingly on sense objects, an inclination towards them is generated.
This inclination develops into desire and desire gives rise to anger.

4. Chapter 2, Verse 63

krodhaadbhavati sammohah sammohaatsmritivibhramah |
smritibhramshaadbuddhinaasho buddhinaashaatpranashyati ||

From anger comes delusion; from delusion, confused memory; from confused memory the ruin of reason; from ruin of reason, man finally perishes.

5. Chapter 6, Verse 5

uddharedaatmanaatmaanam naatmaanamavasaadayeth |
aatmaiva hyaatmano bandhuraatmaiva ripuraatmanah ||

Let a man raise himself by his own efforts. Let him not degrade himself.

Because a person’s best friend or his worst enemy is none other than his own self.

6. Chapter 6, Verse 6

bandhuraatmaatmanastasya yenaatmaivaatmanaa jitah |
anaatmanastu shatrutve vartetaatmaiva shatruvath ||

For a person who has conquered his lower self by the divine self, his own self acts as his best friend. But for that person who has not conquered his lower self, his own self acts as his worst enemy.

7. Chapter 4, Verse 7

yadaa yadaa hi dharmasya glaanirbhavati bhaarata |
abhyuktaanamadarmasya tadaatmaanam srijaamyahamh ||

When there is decay of dharma (righteousness) and rise of adharma (unrighteousness),
then I (the Lord) am born in this world.

8. Chapter 2, Verse 47

karmanyevaadhikaaraste maa phaleshu kadaachana |
maa karmaphalaheturbhuu maatesangotsvakarmani ||

A person has the right towards action alone and not towards the fruit of action. Let not the fruit of action be the motive for acting. Also, Let there not be any attachment to inaction.

9. Chapter 2, Verse 22

vaasaamsi jiirnaani yathaa vihaaya, navaani grihnaati naro aparaani |
tathaa shariiraani vihaaya jiirnaanyanyaani samyaati navaani dehii ||

Just as a person casts off worn out garments and puts on others that are new, even so, the embodies soul casts off worn out bodies and takes on others that are new.

10. Chapter 9, Verse 27

yatkaroshhi yadashnaasi yajjuhoshhi dadaasi yath |
yattapasyasi kaunteya tatkurushhva madarpanamh ||

Arjuna, whatever you do, whatever you eat, whatever you offer (in sacrifice), whatever you give away, whatever you do by way of penance, offer it all to me.

11. Chapter 4, Verse 9

janma karma cha me divyamevam yo vetti tattvatah |
tyaktvaa deham punarjanma naiti maameti so arjuna ||

Arjuna, My birth and activities are divine. He who knows this in reality is not reborn on leaving his body, but comes to Me.

12. Chapter 9, Verse 26

patram pushhpam phalam toyam yo me bhaktyaa prayachchati |
tadaham bhaktyupahritamashnaami prayataatmanah ||

I accept the offering of even a leaf, a flower, fruit or water, when it is offered with loving devotion.

13. Chapter 3, Verse 19

tasmaadasaktah satatam kaaryam karma samachara |
asakto hyaacharankarma paramaapnoti puurushah ||

(Therefore) You must always fulfill all your obligatory duties without attachment. By performing actions without attachment, one attains the Highest.

14. Chapter 3, Verse 37

kaama eshha krodha eshha rajogunasamudbhavah |
mahaashano mahaapaapma viddhyenamiha vairinamh ||

Desire and anger which are born out of passion are insatiable and prompt man to great sin and should be recognized as enemies.

15. Chapter 6, Verse 26

yato yato nishcharati manashcha.nchalamasthiramh |
tatastato niyamyaitadaatmanyeva vasham nayeth ||

By whatever cause the mind, which is restless and fidgeting, wanders away, the yogi should bring it back from that and concentrate only on the Self.

16. Chapter 5, Verse 10

brahmanyaadhaaya karmaani sangam tyaktvaa karoti yah |
lipyate na sa paapena padmapatramivaambhasaa ||

He who offers all actions to God, without attachment, remains untouched by sin, just as a lotus leaf by water.

17. Chapter 18, Verse 65

manmanaa bhava madbhakto madyaajii maam namaskuru |
maamevaishhyasi satyam te pratijaane priyo asi me ||

Give your mind to Me, be devoted to Me, worship Me and bow to Me. Doing so, you will come to Me alone, I truly promise you, for you are so exceptionally dear to Me.

18. Chapter 7, Verse 3

manushhyaanaam sahasreshhu kashchidyatati siddhaye |
yatataamapi siddhaanaam kashchinmaam vetti tatvatah ||

Hardly one among thousands of men strives to realize Me;
Of those who strive, again, only a very rare one (devoting himself exclusively to Me) knows Me in reality.

19. Chapter 8, Verse 5

antakaale cha maameva smaranmuktvaa kalevaramh |
yah prayaati sa madbhaavam yaati naastyatra samshayah ||

He who departs from the body, thinking of Me alone, even at the time of death, will definetely reach Me.

20. Chapter 9, Verse 14

satatam kiirtayanto maam yatantashcha dridhavrataah |
namasyantashcha maam bhaktyaa nityayuktaa upaasate ||

My determined devotees constantly chant My name and glories, strive for realizing Me and worship Me with single minded devotion.

21. Chapter 10, Verse 41

yadyadvibhuutimatsatvam shriimadurjitameva vaa |
tattadevaavagachcha tvam mama tejo nashasambhavamh ||

(Arjuna,) Know that every being that is glorious, brilliant and powerful is nothing but a mainfestation of a small part of my glory.

22. Chapter 11, Verse 12

divi suuryasahasrasya bhavedyugapadutthitaa |
yadi bhaah sadrishii saa syaad hbhaasastasya mahaatmanah ||

Even If the radiance of a thousand Suns, bursts forth all at once in the heavens, it would still hardly approach the splendor of the mighty Lord.

23. Chapter 12, Verse 15

yasmaannodvijate loko lokaannodvijate cha yah |
harshhamarshhabhayodvegairmukto yah sa cha me priyah ||

He, by whom the world is not agitated and whom the world cannot agitate, he who remains calm in times of joy, anger, fear and anxiety, is dear to me.

24. Chapter 1, Verse 40

kulakshaye praNashyanti kuladharmaah sanaatanaah |
dharme nashhte kulam kritsnamh adharmo abhibhavatyuta ||

In the decline of a clan, its ancient traditions perish. When traditions perish, the entire family is indeed overcome by lawlessness.

25. Chapter 2, Verse 27

jaatasya hi dhruvo mrityuh dhruvam janma mritasya cha |
tasmaadaparihaarye arthe na tvam shochitumarhasi ||

Death is certain of that which is born. Birth is certain of that which is dead. Therefore, you should not lament over the inevitable.

26. Chapter 2, Verse 67

indriyaanaam hi charataam yanmano anuvidhiiyate |
tadasya harati pragyaam vaayarnaavamivaambhasi ||

The mind, which follows in the wake of the wandering senses, carries away a man’s discrimination just as a gale tosses a ship on the high seas.

27. Chapter 3, Verse 9

yagyaarthaatkarmano anyatra loko ayam karmabandhanah |
tadartham karma kaunteya muktasangah samaachara ||

Arjuna, In this world all actions become causes of bondage, unless they are performed as an offering to God. Therefore, work for the sake of God, without personal attachments.

28. Chapter 6, Verse 40

paartha naiveha naamutra vinaashastasya vidhyate |
na hi kalyaanakritkashchidh durgatim taata gachchati ||

Oh Arjuna, there is no destruction either in this world or the next, for a spiritually fallen yogi. No man who does good can ever come to ruin.

29. Chapter 9, Verse 30

api chetsuduraachaaro bhajate maamananyabhaakh |
saadhureva sa mantavyah samyagvyavasito hi sah ||

Even a confirmed sinner, if he worships Me with unwavering faith and devotion, must be considered righteous, because, he has decided to reform himself.

30. Chapter 18, Verse 66

sarvadharmaanparityajya maamekam sharanam vraja |
aham tvaa sarvapaapebhyo mokshayishhyaami maa shuchah ||

Abandoning all paths, come to Me as the only refuge. Grieve not, for I will liberate you from all sins.

31. Chapter 18, Verse 78

yatra yogeshvarah krishhno yatra paartho dhanurdharah |
tatra shriirvijayo bhuutirdhruvaa niitir matirmama ||

Wherever there is Krishna, the Lord of Yoga and the bow weilding Arjuna, there reign good fortune, victory, prosperity and justice. Such is my conviction.

User Interface Design Basics and Fundamental Principles

User Interface Design Basics and Fundamental Principles

User Interface / UI Design focuses on what users might need to do and ensuring that the interface has elements that are easy to access, understand, and use to facilitate the actions.

UI is all about the concepts of interaction design, visual design, and information architecture.

Choosing Interface Elements

Users have become familiar with interface elements and acting in a certain way; So try to be consistent & predictable in your choices with the layout, Doing so will help with task completion, efficiency, and satisfaction.

Interface elements include but are not limited to:

  • Input Controls: buttons, text fields, checkboxes, radio buttons, dropdown lists, list boxes, toggles, date field
  • Navigational Components: breadcrumb, slider, search field, pagination, slider, tags, icons
  • Informational Components: tooltips, icons, progress bar, notifications, message boxes, modal windows
  • Containers: accordion

Best Practices for Designing an Interface

Everything stems from knowing your users, including understanding their goals, skills, preferences, and tendencies.  Once you know about your user, make sure to consider the following when designing your interface:

  • Keep the interface simple & Know your user: The best interfaces are almost invisible to the user. They avoid unnecessary elements and are clear in the language they use on labels and in messaging.
    Your user’s goals are your goals, so learn them. Restate them, repeat them. Then, learn about your user’s skills and experience, and what they need. Find out what interfaces they like and sit down and watch how they use them. Do not get carried away trying to keep up with the competition by mimicking trendy design styles or adding new features. By focusing on your user first, you will be able to create an interface that lets them achieve their goals.
  • Pay attention to patterns: Users spend the majority of their time on interfaces other than your own (Facebook, MySpace, Blogger, Bank of America, school/university, news websites, etc). There is no need to reinvent the wheel. Those interfaces may solve some of the same problems that users perceive within the one you are creating. By using familiar UI patterns, you will help your users feel at home.
  • Be consistent and use common UI elements: Users need consistency. They need to know that once they learn to do something, they will be able to do it again. By using common elements in your UI, users feel more comfortable and are able to get things done more quickly.  It is also important to create patterns in Language, layout, and design are just a few interface elements that need consistency throughout the site to help facilitate efficiency.
    A consistent interface enables your users to have a better understanding of how things will work, increasing their efficiency.
  • Be purposeful in page layout & Keep it simple:  Consider the spatial relationships between items on the page and structure the page based on importance. Careful placement of items can help draw attention to the most important pieces of information and can aid scanning and readability.
  • Strategically use color and texture: You can direct attention toward or redirect attention away from items using color, light, contrast, and texture to your advantage.
  • Use typography to create hierarchy and clarity: Carefully consider how you use typeface. Different sizes, fonts, and arrangement of the text to help increase scanability, legibility and readability.
  • Make sure that the system communicates what’s happening:  Always inform your users of location, actions, changes in state, or errors. The use of various UI elements to communicate status and, if necessary, next steps can reduce frustration for your user.
  • Think about the defaults: By carefully thinking about and anticipating the goals people bring to your site, you can create defaults that reduce the burden on the user.  This becomes particularly important when it comes to form design where you might have an opportunity to have some fields pre-chosen or filled out.

Adolf Hitler – Think Thousand times

Think Tausendmal bevor sie eine Entscheidung aber – Nach der Entnahme Entscheidung nie wieder einschalten, selbst wenn Sie Thousand Schwierigkeiten geraten!


Think Thousand times before taking a decision But – After taking decision never turn back even if you get Thousand difficulties!!

― Adolf Hitler