Wednesday, 14 December 2016

Rough Draft , Notes

Should we use foreign keys?
 Referential integrity
Performance hit

But the performance hit is only when there are a lot of foregin keys. Because for each row inserted,updated,deleted other tables would also be checked
However, foregin keys helps in optimizing queries and increase reading speed
By default indexes aren't created on foreign keys.
Stackoverflow Link

Jackson Json: How to prevent field serialization?
@JsonIgnore or mark the field as transient

Jacson Json vs Gson
Jackson seems to be winning the race. It has a lot of benefits over Gson and performance is also better.
Spring has default support of jackson.

What's the use of identityhashmap?
It's use is rare, it's used when objects are to be compared via reference equality == and not equals method. Thus, it kinds of break map equals contract ,

 Pipelining can give a big performance boost
Pipelining is used to save RTT(Round trip time), pipelining is nothing but a series of commands sent as one
Redis provides transactions to execute a series of commands
Write MULTI to start, now all the commands will be put in queue, enter EXEC to execute all or DISCARD to discard all. In case something went wrong in between rest will be executed. NO ROLLBACK. Redis supports NO ROLLBACK

Redis scripts are transactional by definition, in future transactions might be deprecated and only scripts will be used.

Redis Memory setting
in redis.conf: maxmemory 100mb, setting it to 0 means no limit, when limit has reached there can be several different eviction policies, noeviction, lru, volatile-lru, etc
Redis doesn't uses true lru,  only apprroximation, a set of keys, to save memory, however setting of sample size can be changed

Redis Cluster
In redis cluster, single db is available, operations involving multiple keys might not be avialable
supports upto 1000 nodes

Read: Redis in Action

Seven Databases in seven weeks
Seven Languages in seven weeks
Seven Web Frameworks in seven weeks

Java SE8 for really impatient


List at least three ways to communicate between modules of your application using core AngularJS functionality.
Which means of communication between modules of your application are easily testable?
The most popular e2e testing tool for AngularJS is Protractor. There are also others which rely on similar mechanisms. Describe how e2e testing of AngularJS applications work.
When a scope is terminated, two similar “destroy” events are fired. What are they used for, and why are there two?
How do you reset a “$timeout”, and disable a “$watch()”?
Name and describe the phases of a directive definition function execution, or describe how directives are instantiated.
How does interpolation, e.g. “{{ someModel }}”, actually work?
How does the digest phase work?
List a few ways to improve performance in an AngularJS app.
What is $rootScope and how does it relate to $scope?
What is AngularJS?
What is data binding in AngularJS?
What is scope in AngularJS?
What are the controllers in AngularJS?
What are the services in AngularJS?
What are the filters in AngularJS?
Explain directives in AngularJS.
Explain templates in AngularJS.
What is routing in AngularJS?
What is deep linking in AngularJS?
What are the advantages of AngularJS?
What are the disadvantages of AngularJS?
Which are the core directives of AngularJS?
Explain AngularJS boot process.
What is MVC?
Explain ng-app directive.
Explain ng-model directive.
Explain ng-bind directive.
Explain ng-controller directive.
How AngularJS integrates with HTML?
Explain ng-init directive.
Explain ng-repeat directive.
What are AngularJS expressions?
Explain uppercase filter.
Explain lowercase filter.
Explain currency filter.
Explain filter filter.
Explain orderby filter.
Explain ng-disabled directive.
Explain ng-show directive.
Explain ng-hide directive.
Explain ng-click directive.
How angular.module works?
How to validate data in AngularJS?
Explain ng-include directive.
How to make an ajax call using Angular JS?
What is use of $routeProvider in AngularJS?
What is $rootScope?
What is scope hierarchy in AngularJS?
What is a service?
What is service method?
What is factory method?
What are the differences between service and factory methods?
Which components can be injected as a dependency in AngularJS?
What is provider?
What is constant?
Is AngularJS extensible?
On which types of component can we create a custom directive?
What is internationalization?
How to implement internationalization in AngularJS?

What is notion of directives in AngularJS?
Name some of the most commonly used directives? What is uage of ng-app, ng-controller, ng-view, ng-model etc?
Explain how MVC is achieved with AngularJS? What are the benefits of client-side MVC, in general?
What is $scope object? Who injects it? Why is it used?
What is $scope.$apply and $scope.$digest method?
What is two-way data binding? Give an example?
Give an example of dependency injection with respect to AngularJS?
What is concept of routing? Show with an example? What Angular module is required to execute routing functionality?
How could one create single-page application using AngularJS? Which provider is used to achieve this objective?
What setup may be needed to do unit testing with AngularJS? What features of Angular come handy for doing unit tests?

  1. Can the angular application be initialized on only HTML element or ANY element?
    Ans: ANY element
  2. Can an HTML page have multiple “ng-app” directive for bootstrapping multiple AngularJS application?
    Ans: Yes
  3. With more than one ng-app in an HTML document (an HTML page), are they automatically initialized? Describe the angularJS application initialization process with multiple ng-app in an HTML document/page.
    Ans: Only one AngularJS application can be auto-bootstrapped. The first ‘ng-app’ found in the document will be used to define the root element to auto-bootstrap as an application. To run multiple applications in an HTML document, one must manually bootstrap them using angular bootstrap service.
  4. Describe the steps involved in bootstrapping an angular application?
    Ans: Following steps are involved in bootstrapping the angular application:
    • Determine the element consisting of ng prefixes with “app”
    • Check whethar an angular app already exists on the element
    • Compile & link with the help of dependencies such as rootScope injected (used for linking).
  5. Can angular applications (ng-app) be nested within each other?
    Ans: No
  6. What are various possible prefixes such as “ng-” using which Angular directives (for example, ng-app) can be defined?
    Ans: “ng-“, “data-ng-“, “ng:”, “x-ng-“
  7. What are various possible ways in which angular application can be initialized?
    Ans: On an element, one could either put simply the attribute such as (ng-app, data-ng-app, ng:app, x-ng-app) or put the named attribute such as (ng-app=”demoApp”).
  8. What angular function is used to manually start up an angular application?
    Ans: angular.bootstrap
  9. Can multiple angular applications be bootstrapped using same element?
    Ans: No. An error is thrown such as “App Already Bootstrapped with this Element”
  10. At framework level, how does Angular retrieve the matching elements for processing?
    Ans: Makes use of jqLite(element) function. If jQuery is used, jQuery(element) is used by way of assigning jQuery to jqLite variable.>

Monday, 12 December 2016

Java all Part II

Why we can't do subtyping in generics?

Why generics array can't be created?

What are the new features in Java 8?
-foreach,spliterator in interable interface

What is Spliterator?

What is Consumer interface?

What is Predicate interface?

What is functional interface?
An interface with exactly one abstract method becomes Functional Interface.

What is the use of functional interface?
It's greate to use it in lambda expressions.

What are Single Abstract Method interfaces(SAM)?

default vs static in interface?
We can't override static. static is indeed static, it isn't inherited, can be used directly with Interface name. So, now interface can contain static methods.

What is the use of @FunctionalInterface annotation?
We don’t need to use @FunctionalInterface annotation to mark an interface as Functional Interface. @FunctionalInterface annotation is a facility to avoid accidental addition of abstract methods in the functional interfaces. You can think of it like @Override annotation and it’s best practice to use it. 

What is map reduce?
map function transforms input like doubling each value, reduce function convert list to some value like average,sum,etc.

What new methods have been added to Collection iterface?

What new methods have been added to Iterable interface?

What new methods have been added to Map interface?

Stream vs parallel stream?

Flatten a stream of list of stream.

Jdbc in java8

What is jdbc-odbc bridge, why is it removed in Java8?

Benefits of lambda expressions?

Method reference?

Constructor reference?

Repeated annotation?