Object Oriented Programming System(OOPS) =============================================== * To develop a software system, there are 2 programming paradigms are available. 1. Procedure Oriented Programming model 2. Object Oriented Programming model * In Procedure Oriented Programming model(POP), software systems are developed by creating functions/procedures. * For example, The programming languages like C and Pascal are POP languages. * With POP, the disadvantages are, 1. more complexity 2. no modularity 3. no real-world mapping 4. no scalability * So, POP model is only suitable for designing and implementing smaller systems. * To overcome the limitations in POP model, in early 1980's OOP model was introduced. * OOP model has defined some principles/practices to design and implement reusable and maintainable software systems. * Those principles are, 1. Encapsulation 2. Inheritance 3. Polymorphism 4. Abstraction Encapsulation: * Encapsulation is a word derived from another word, "capsule". * In medical terms, "capsule" is a single unit, where we can keep some powder and nuts together. * Similiarly, In programming, a class is used to implement this encapsulation principle/practice. * By using a class, we can keep the data and related functionality together with proper access modifiers, we can implement encapsulation. * With encapsulation, we can prevent accidentally modifying the data by the outside world. Inheritance: * Inheritance is a process of acquiring/inheriting the properties and behaviour from one class to another class. * Inheritance provides the advantages like, 1. code reusability 2. improves developers productivity 3. reduces redundency Polymorphism: * Polymorphism is a combination of two Greek words. * Poly means many and morphism means forms. So polymorphism represents "many forms". * Polymorphism denotes that a software should provide many ways to perform an action. * For example, a customer can open a bank account by providing adhaar card or voter id or pan card as a proof. So, the application has provided many ways to perform an action. Abstraction: * Abstraction is a process of providing the essential information to the user of the system, by hiding non-essential information. * For example, when you download a file from a website/application, the essential information will be shown to the user like the filname and the size and also how long time it will take to download the file. But the other details like physical location of the file, which programming is used to develop the application, etc.. are not shown to the user. This is called abstraction. * In Java, abstraction can be implemented using abstract classes and interfaces. ===================================================================== class & object: -------------------- * A class is a template or blueprint for constructing a group of objects with similar attributes and behavior. * The attributes are also called properties or variables and the behaviour is also called functionality or methods. * A class is a collection of variables and methods for a group of objects. * A class is a word took from another word classification. * An object is an instance of a class, which contains the values for the variables created in a class. * At runtime of an application, the object exist in memory of JVM, but not the class. syntax of a class: class { variables; methods; } ex: public class Policy { int policyId; String policyType; String policyHolder; void calculatePremium() { //logic } void showPolicyDetails() { //logic } } syntax of creating an object: classname objectname = new classname(); ex: Policy policy1 = new Policy(); ============================================================