Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

9 crucial Java Design Principles you cannot miss

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Prochain SlideShare
Hibernate3 q&a
Hibernate3 q&a
Chargement dans…3
×

Consultez-les par la suite

1 sur 11 Publicité

9 crucial Java Design Principles you cannot miss

Télécharger pour lire hors ligne

Encapsulation, Polymorphism, Agreggation / Composition, Overloading, Inheritance vs Composition, DRY, Dependency Injection, Delagation, Law of demeter, Principle of leas knowledge,

Encapsulation, Polymorphism, Agreggation / Composition, Overloading, Inheritance vs Composition, DRY, Dependency Injection, Delagation, Law of demeter, Principle of leas knowledge,

Publicité
Publicité

Plus De Contenu Connexe

Diaporamas pour vous (20)

Similaire à 9 crucial Java Design Principles you cannot miss (20)

Publicité

Plus récents (20)

Publicité

9 crucial Java Design Principles you cannot miss

  1. 1. 1/9 What is Encapsulation ? Much of object programming is centered on minimizing the ripple effects caused by changes to a program. This is done simply by keeping details secret The principal ways of doing this are: - minimizing visibility - private fields, package-private classes (grouping into 1 domain package: entity,repository,service,controller) - generic references (polymorphism) - using high level references (interfaces or abstract classes) instead of low level references (concrete classes)
  2. 2. 2/9 What is Polymorphism ? The point of polymorphism is that you can subclass a class and the objects implementing those subclasses will have different behaviors for the same methods defined in the superclass (and overridden in the subclasses).
  3. 3. 3/9 What is Aggregation / Composition ? has-a relationship
  4. 4. 4/9 What is Method Overloading ? If a class has multiple methods by same name but different parameters
  5. 5. 5/9 Inheritance vs Compositions ? inheritance - Java doesnt support multiple inheritance (till java 8 , where we have default methods ) composition - Use private members inh - you need super class instance comp - easy to create Mock Object representing composed class inh - it breaks encapsulation, when behavior of super class changes, functionality in sub class may get broken comp - you are flexible enough to replace implementation of Composed class with better and improved version. inh - Inheritance makes much sense like when a genuine parent child relation exists comp - In Decorator pattern, we dont extend any class to add additional functionality Instead we keep an instance of the class we are decorating and delegates original task to that class after doing decoration
  6. 6. 6/9 What is DRY ? avoid duplication for functionality , use dependency injection if needed. but you can repeat same code (ie user authorization) for different functionalities in micro services or micro functionalities
  7. 7. 7/9 What is Dependency Injection ? Class injected by DI framework is easy to test with mock object Easier to maintain because object creation code is centralized in framework Done in Spring via proxies
  8. 8. 8/9 What is Delegation ? delegate tasks to ie: equals, hashcode methods, thread pools do not do it yourself on client side
  9. 9. 9/9 What is Law of Demeter / Principle of least knowledge ?

×