Popular posts from this blog
Butter Knife: ease to bind view in activity
ButterKnife is an open source that eases the way to bind view in activity class. Below is the example: 1. In build gradle, compile 'com.jakewharton:butterknife:8.5.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 2. Suppose there are two buttons having id - android :id= "@+id/hiBtn" android :id= "@+id/byeBtn" 3. In activity .java class, a. Initialize your binding button variable as- @BindView (R.id. hiBtn ) Button hiBtn ; @BindView (R.id. byeBtn ) Button bye Btn ; b. For Activity class, in onCreate() method, ButterKnife. bind ( this ); For Fragment class, in onCreateView() method View view = inflater.inflate(R.layout.fancy_fragment, container, false ); ButterKnife.bind( this , view); c. And the button click event as, ...
Liskov Substitution Principle (LSP)
Subtypes must be substitutable for their base types. This principle supports the below scenario- Suppose a method takes parent type and perform some operation on it. And the subtype is not of type - parent but still wrongly inherits the parent. If the above subtype object is passed to such method, the operation performed will be weird as the method assumes it is suppose to be parent type. Hence, a class should inherit parent only if its of that type. (eg: Square is not Rectangle programmatically as the area is always side^2)

Comments
Post a Comment