Your SlideShare is downloading. ×
JAVA design patterns and Basic OOp concepts
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

JAVA design patterns and Basic OOp concepts

1,042
views

Published on

This Presentation is about java design patterns. I have covered some OOPs concepts as well: Polymorphism, Interface, Inheritance, abstraction etc. And the Main Topic Covers: Factory Design …

This Presentation is about java design patterns. I have covered some OOPs concepts as well: Polymorphism, Interface, Inheritance, abstraction etc. And the Main Topic Covers: Factory Design Patterns,Observer Design Patterns,Proxy Design Patterns,Adapter Design Patterns,MVC Design Patterns etc

Published in: Education, Technology

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,042
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
68
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. What is Java? Programming Language Fast Secure Reliable
  • 2. What is Java? Programming Language Fast Secure Reliable
  • 3. Some Facts about JAVA: Developed by JAMES GOSLING at SUN MICROSYSTEMS Related to two languages C and C++ HOW ? JAVA derives its Syntax from C and, Many concepts based on OOPs were influenced by C++ Initially JAVA was named as “Oak” But was renamed by “JAVA” in 1995 3977 classes
  • 4. The Way JavaWorks : Objective :Write an Application and make it run on whether devices your friends have.
  • 5. The JAVA BUZZWORDS : Simple Secure Portable Dynamic Distributed Object-oriented Robust(Consistent) Multithreaded Architecture neutral High Performance
  • 6. Major OOP Principles : Abstraction Encapsulation Inheritance Polymorphism
  • 7. Abstraction:  Manages Complexity(Generalization)  Hierarchal Classification  Makes Java more Understandable
  • 8. Encapsulation: Binds Code and data Together Keeps it safe from outside interference and Misuse It works through Classes. A AB C CD C is accessible with in this Block
  • 9. Inheritance : Process of acquiring the properties of another object In absence of inheritance, each object needs to define all characteristics
  • 10. Polymorphism : An Ability of an object to acquire more than one form For example: public interface Vegetarian{ } public class Animal{ } public class Deer extends Animal implements Vegetarian{ } A Deer IS-A Animal A Deer IS-A Vegetarian A Deer IS-A Deer A Deer IS-A Object
  • 11. Interface :  It is an Collection of Abstract Methods  It can contain any no. of methods  How do it do this??? HOW ?
  • 12. Lets Design Some Patterns General solution to programmers problems faced while designing software Increase the Code Maintainability GOF: Erich Gamma, Richard helm, Ralph Johnsons and John vlissides Helps in Reusing the codes Time saving and Cost reduction
  • 13. Types Of Patterns Creational Pattern: Way to create Objects while hiding the Creational Logic Structural Pattern: Concerns class and object composition Behavioral pattern: Referred to communication between objects J2EE: Presentation tier.
  • 14. Classification Of Patterns Creational pattern: 1. Factory Pattern 2. Singleton Pattern 3. Abstract Factory Pattern 4. Builder Pattern 5. Prototype Pattern Structural Patterns: 1. Adapter Pattern 2. Composite Pattern 3. Proxy Pattern 4. Flyweight Pattern 5. Façade Pattern 6. Bridge Pattern 7. Decorator Pattern Behavioral Pattern: 1. Template Method Pattern 2. Mediator Pattern 3. Chain of Responsibility Pattern 4. Observer Pattern 5. Strategy Pattern 6. Command Pattern 7. State Pattern 8. Visitor Pattern 9. Iterator Pattern 10. Memento Pattern
  • 15. Factory Pattern
  • 16. Factory Pattern Comes Under the creational Pattern Create object without Exposing the Creational Logic used to instantiate an object from one among a set of classes based on a logic Assume that you have a set of classes which extends a common super class or interface. Now you will create a concrete class with a method which accepts one or more arguments.This method is our factory method.
  • 17. Factory Pattern Super Class SubClass 3Sub Class 2Sub Class 1 Factory Super ClassLogic
  • 18. Factory Pattern
  • 19. Adapter Pattern Allows you to use two Incompatible Interfaces to work together Used when the client expects a(target) interface Adapter Class allows the use of available Interface and the target  interface Any class can work together as long as the Adapter solves the issue that All classes must implements every method defined by the shared interface
  • 20. Adapter Pattern Client Enemy Attacker <Interface> Fire weapon():void Drive Forward():void Assign driver():void Enemy Robot Adapter Fire weapon():void Drive Forward():void Assign driver():void Enemy Robot Smash with hands():void walk Forward():void React to human():void Enemy Robot Enemy Attacker (Target) Enemy Robot Adapter (Adaptor) Enemy Robot (Adaptee)
  • 21. Adapter Pattern
  • 22. Observer Pattern In observer design pattern multiple observer objects registers with a subject for change notification.When the state of subject changes, it notifies the observers. Objects that listen or watch for change are called observers and the object that is being watched for is called subject. Pattern involved is also called as publish-subscribe pattern. Model view controller (MVC) architecture’s core uses the observer design pattern.
  • 23. Observer Pattern Subject provides interface for observers to register and unregister themselves with the subject. Subject knows who its subscribers are. Multiple observers can subscribe for notifications. Subject publishes the notifications. Subject just sends the notification saying the state has changed. It does not pass any state information. Once the notification is received from subject, observers call the subject and get data that is changed.
  • 24. Observer Pattern Consider an excel sheet, data is shown to the user in different views. Generally data is shown in grid cells and as required different graphs, charts can be created for same data. Underlying data is same and when that data (subject) state changes all the different view are updated.  When multiple objects depend on state of one object and all these multiple objects should be in sync with the state of this one object then observer design pattern is the right choice to apply. When?
  • 25. Observer Pattern Let us take a blog and subscriber example for observer design pattern sample implementation. Assume that there is a blog and users register to that blog for update.When a new article is posted in the blog, it will send update to the registered users saying a new article is posted.Then the user will access the blog and read the new article posted. In this example, blog is the subject and user is the observer.
  • 26. Proxy Design Pattern Proxy means ‘in place of’. In attendance roll call, we give proxy for our friends in college right? ‘Representing’ or ‘in place of’ or ‘on behalf of’ are literal meanings of proxy and that directly explains proxy design pattern.
  • 27. Proxy Design Pattern Remote Proxy – Represents an object locally which belongs to a different address space.Think of an ATM implementation, it will hold proxy objects for bank information that exists in the remote server. Virtual Proxy – In place of a complex or heavy object use a skeleton representation. Protection Proxy –working on a MNC? If so, you might be well aware of the proxy server that provides you internet. Saying more than provides, the right word is censors internet. Smart Reference – Just we keep a link/reference to the real object a kind of pointer.
  • 28. Proxy Design Pattern Provide a class which will limit access to another class You may do this for Security reasons, because an Object is intensive to Create, or is accessed from a remote location.
  • 29. Proxy Design Pattern Client GetATMState <interface> +getATMState(): ATMState +getCashINMachine():int ATM Proxy +getATMState(): ATMState +getCashINMachine():int ATM Machine +getATMState(): ATMState +getCashINMachine():int
  • 30. MVC Design Pattern Completely Separates the Calculation and Interface from each other Model: Data and Model Used to Work with it View:The Interface Controller: Coordinates interactions between the view and Model My Favorite One!!
  • 31. Rahul Malhotra rahulbtibusiness@gmail.com +91-74041-37709 www.facebook.com/btiworld14