Monday, January 27, 2020

OOPS

OOPS concepts----------------------------------------------------------------------------
OOP programming  runs around below keywords.
Object oriented programming used to simulate real life things into your code is called as OOP.

OOPS 2 entities:
Class:(blue print of object) is a specification of object
       It is having name, properties and methods.
Ex: College student details: attributes/data members and functions and method.
Object: (instance of a class) is a peace of code which represent the real life entity.
      Object will be having its own identity,  properties and behavior.
Ex: the black[property] dog[object] barks[behavior]
Ex: TennisCourt:  here court is object Court has attributes like color, surface, dimensions etc called variables/data members, and functionality like court booking, court cleaning etc called functions/methods.
Change in attributes will change the behavior of members object.

OOPs 4 Principles:
  • Encapsulation: Encapsulation is the mechanism of binding the data and methods together and hiding it from the outside world. Encapsulation is achieved by keeping its state private(access specifiers) so that other objects don’t have direct access to its state. Instead, they can access this state only through a set of public methods. Ex: Capsul tablet which is encapsulated with medicine and chemicals. 
  • Abstraction: Abstraction will help by hiding internal implementation details of objects and only exposes the operations that are relevant to objects. Ex: Student can have multiple attributes but we take which are relevant for college i.e name , age and rool number, as college no need to know his girl friends names, his child hood school friends etc i.e means only relevant for that business.
  • Inheritance: Inheritance is the mechanism of creating new classes from existing ones. Which help in reusability. It works on relationship. One object aquires the properties of other object.
  • Polymorphism: Polymorphism (from Greek, meaning “many forms”) is the ability of an object to take different forms and thus, depending upon the context, to respond to the same message in different ways. Take the example of a chess game; a chess piece can take many forms, like bishop, castle, or knight and all these pieces will respond differently to the ‘move’ message.
Design-----------------------------------
Design always should follow 3 things
DRY- Donot repeat yourself
Divide and Conquer - Code keep on adds in a file its difficult to change
Expect Change - Always new features should come which requires the change.

SOLID:
S - Single responsible principle : Class should have only one reason to change, it can change multiple times but it should change for only with its context of cricket.
Ex: Sachin performance only  vary because of sporting reasons not because of BCCI president changed, or Needs to do act in add i.e this things should not be the reasons to change.

O - Open for extension and closed for modification : Create interface and add concrete classes for each type of base interface. Ex; IPayment  having makePayment() function and all sub classes like CardPayment , Cash payment, should have makepayment method so tomorrow if online payment comes without changing existing concrete classes we will add OnlinePayment class with make paymethod where u need use name password for login and then pay.

L- Liskov's substitution principle: Child class should able to substitute the base class functionality.
Example; Don and his 3 sons , one son is not his actual son his neighbor son who is a cook, then he will not replace which  his father dead, instead of killing enemies he will serve tea, copy etc.

I- Interface Segregation Principle : Do not force any client class should not implement interface which is irrelevant for it.

D- Dependency inversion principle: Responsibility of creation of dependency object should outsource to the consuming class.

Practices-----------------------------------------------------------------------
OO Analysis and Design means: Identifying the objects for the problem, and relation between the objects and providing the interface for each object.
1. Collect the requirement
Write all the requirement with pen and paper/white board or use tools/ system.

   - functional requirement: what is the needed the application look, work what all boundaries.
   Non func. requirement:
     - performance requirement
     - Security requirement : data access etc
     - documentation, support
 Map the requirements to technical description.
    Use cases:
          - title:  short description of use cases,
          - actor : user how he interact with use cases (who all involved, like system admin class, person class, data base etc.)
          - scenario: how the scenario works.
   
2. Describe the system in brief  or write the wire frames.
3. Identify the classes
4. create the uml diagrams[sequence, use case, etc] 
UML:(Unified modeling language) :
    Graphical notation to easily can be conveyed the business/ software system.

Many diagram types:class diagram, Object diagram, use case diagram, activity diagram, sequence diagram and state/communication/interaction diagram.
Association, multiplicity, aggregation, composition, Generalization, Dependency and abstract class.
use case diagram: Oval on center of diagram with use case name in oval,  include  and  extend string.
class diagram: has a rectangle with 3 horizontal section upper section shows the class name, middle section shows properties/ variables/data of class and lower section contains method/function names called class operations. 
Sequence diagram: across the top of your diagram, identify the class instances(object) by putting each class inside a box. 

No comments:

Post a Comment

Port forwarding issues and port collusion by more then one process

Port forwarding script to identify collusions  Identifying local and remote port forwarding processes, as well as checking for potential col...