├── oops-concepts ├── images │ ├── Cohesion.png │ ├── coupling.png │ ├── abstraction.png │ ├── aggregation.png │ ├── association.png │ ├── encapsulation.png │ ├── runtime-poly.png │ ├── aggregation (1).png │ ├── association (1).png │ ├── composition (1).png │ ├── Hybrid Inheritance.png │ ├── Single Inheritance.png │ ├── multiple inheritance.png │ ├── Multilevel Inheritance.png │ ├── inheritance-java-core.png │ ├── Hierarchical Inheritance.png │ └── Hybrid Inheritance.xml ├── .settings │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.jdt.core.prefs ├── target │ └── classes │ │ ├── META-INF │ │ ├── MANIFEST.MF │ │ └── maven │ │ │ └── com.ramesh.ood │ │ │ └── oops-concepts │ │ │ ├── pom.properties │ │ │ └── pom.xml │ │ └── com │ │ └── ramesh │ │ └── ood │ │ └── concepts │ │ ├── inheritance │ │ ├── Dog.class │ │ ├── Animal.class │ │ └── Inheritance.class │ │ ├── abstraction │ │ ├── Person.class │ │ ├── Employee.class │ │ ├── Abstraction.class │ │ ├── Contractor.class │ │ └── FullTimeEmployee.class │ │ ├── aggregation │ │ ├── Product.class │ │ ├── LineItem.class │ │ └── Aggregation.class │ │ ├── composition │ │ ├── Order.class │ │ ├── Product.class │ │ ├── LineItem.class │ │ └── Composition.class │ │ ├── loosecoupling │ │ ├── Bike.class │ │ ├── Car.class │ │ ├── Vehicle.class │ │ ├── BadTraveler.class │ │ ├── GoodTraveler.class │ │ └── LooseCoupling.class │ │ ├── delegation │ │ ├── AirBooking.class │ │ ├── Delegation.class │ │ ├── TrainBooking.class │ │ ├── TravelBooking.class │ │ └── TicketBookingByAgent.class │ │ ├── encapsulation │ │ ├── Person.class │ │ └── Encapsulation.class │ │ └── polymorphism │ │ ├── Payment.class │ │ ├── CashPayment.class │ │ ├── CreditPayment.class │ │ └── Polymorphism.class ├── src │ └── main │ │ └── java │ │ └── com │ │ └── ramesh │ │ └── ood │ │ └── concepts │ │ ├── abstraction │ │ ├── Contractor.java │ │ ├── FullTimeEmployee.java │ │ ├── Employee.java │ │ └── Abstraction.java │ │ ├── polymorphism │ │ └── Polymorphism.java │ │ ├── loosecoupling │ │ └── LooseCoupling.java │ │ ├── inheritance │ │ └── Inheritance.java │ │ ├── delegation │ │ └── Delegation.java │ │ ├── aggregation │ │ └── Aggregation.java │ │ ├── encapsulation │ │ └── Encapsulation.java │ │ └── composition │ │ └── Composition.java ├── pom.xml ├── .project └── .classpath ├── oops-principles ├── .settings │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.jdt.core.prefs ├── target │ └── classes │ │ ├── META-INF │ │ ├── MANIFEST.MF │ │ └── maven │ │ │ └── com.ramesh.ood │ │ │ └── oops-principles │ │ │ ├── pom.properties │ │ │ └── pom.xml │ │ └── com │ │ └── ramesh │ │ └── ood │ │ └── principles │ │ ├── interfacesegregation │ │ ├── README.md │ │ ├── bad │ │ │ ├── MediaPlayer.class │ │ │ ├── DivMediaPlayer.class │ │ │ ├── VlcMediaPlayer.class │ │ │ ├── ClientTestProgram.class │ │ │ ├── WinampMediaPlayer.class │ │ │ └── VideoUnsupportedException.class │ │ └── good │ │ │ ├── DivMediaPlayer.class │ │ │ ├── VlcMediaPlayer.class │ │ │ ├── AudioMediaPlayer.class │ │ │ ├── VideoMediaPlayer.class │ │ │ ├── ClientTestProgram.class │ │ │ ├── WinampMediaPlayer.class │ │ │ ├── VideoUnsupportedException.class │ │ │ └── interfacesegregation_principle_good.png │ │ ├── dependencyinversion │ │ ├── bad │ │ │ ├── App.class │ │ │ ├── Customer.class │ │ │ ├── CustomerDao.class │ │ │ ├── DataSource.class │ │ │ ├── DatabaseConfig.class │ │ │ ├── MySQLDataSource.class │ │ │ ├── VoiletCustomerDaoImpl.class │ │ │ └── dependencyinversion_principles_bad.png │ │ └── good │ │ │ ├── App.class │ │ │ ├── Customer.class │ │ │ ├── DataSource.class │ │ │ ├── CustomerDao.class │ │ │ ├── H2DataSource.class │ │ │ ├── CustomerDaoImpl.class │ │ │ ├── DatabaseConfig.class │ │ │ ├── MySQLDataSource.class │ │ │ ├── MSServerConnection.class │ │ │ └── dependencyinversion_principles_good.png │ │ ├── singleresponsibility │ │ ├── bad │ │ │ ├── User.class │ │ │ ├── IUserService.class │ │ │ ├── UserService.class │ │ │ ├── UserService$1.class │ │ │ └── singleresponsibility_principles_bad.png │ │ └── good │ │ │ ├── User.class │ │ │ ├── EmailInfo.class │ │ │ ├── UserService.class │ │ │ ├── EmailService$1.class │ │ │ ├── EmailService.class │ │ │ ├── IEmailService.class │ │ │ ├── IUserService.class │ │ │ └── singleresponsibility_principles_good.png │ │ ├── liskovssubstitution │ │ ├── bad │ │ │ ├── MediaPlayer.class │ │ │ ├── DivMediaPlayer.class │ │ │ ├── VlcMediaPlayer.class │ │ │ ├── ClientTestProgram.class │ │ │ ├── WinampMediaPlayer.class │ │ │ ├── VideoUnsupportedException.class │ │ │ └── liskovssubstitution_principle_bad.png │ │ └── good │ │ │ ├── MediaPlayer.class │ │ │ ├── DivMediaPlayer.class │ │ │ ├── VlcMediaPlayer.class │ │ │ ├── AudioMediaPlayer.class │ │ │ ├── ClientTestProgram.class │ │ │ ├── VideoMediaPlayer.class │ │ │ ├── WinampMediaPlayer.class │ │ │ └── VideoUnsupportedException.class │ │ └── openclosed │ │ ├── bad │ │ ├── ConnectionProvider.class │ │ ├── IConnectionProvider.class │ │ └── openclosed_principle_bad.png │ │ └── good │ │ ├── IConnetionProvider.class │ │ ├── H2ConnectionProvider.class │ │ ├── MySQLConnectionProvider.class │ │ ├── OracleConnectionProvider.class │ │ ├── openclosed_principle_good.png │ │ └── MsServerConnectionProvider.class ├── src │ └── main │ │ └── java │ │ └── com │ │ └── ramesh │ │ └── ood │ │ └── principles │ │ ├── dependencyinversion │ │ ├── good │ │ │ ├── MSServerConnection.java │ │ │ ├── dependencyinversion_principles_good.png │ │ │ ├── DataSource.java │ │ │ ├── DatabaseConfig.java │ │ │ ├── H2DataSource.java │ │ │ ├── MySQLDataSource.java │ │ │ ├── CustomerDao.java │ │ │ ├── Customer.java │ │ │ ├── App.java │ │ │ ├── CustomerDaoImpl.java │ │ │ └── dependencyinversion_principles_good.ucls │ │ └── bad │ │ │ ├── dependencyinversion_principles_bad.png │ │ │ ├── DataSource.java │ │ │ ├── DatabaseConfig.java │ │ │ ├── CustomerDao.java │ │ │ ├── MySQLDataSource.java │ │ │ ├── App.java │ │ │ ├── Customer.java │ │ │ ├── VoiletCustomerDaoImpl.java │ │ │ └── dependencyinversion_principles_bad.ucls │ │ ├── interfacesegregation │ │ ├── README.md │ │ ├── good │ │ │ ├── interfacesegregation_principle_good.png │ │ │ ├── AudioMediaPlayer.java │ │ │ ├── VideoUnsupportedException.java │ │ │ ├── VideoMediaPlayer.java │ │ │ ├── WinampMediaPlayer.java │ │ │ ├── DivMediaPlayer.java │ │ │ ├── VlcMediaPlayer.java │ │ │ ├── ClientTestProgram.java │ │ │ └── interfacesegregation_principle_good.ucls │ │ └── bad │ │ │ ├── VideoUnsupportedException.java │ │ │ ├── MediaPlayer.java │ │ │ ├── VlcMediaPlayer.java │ │ │ ├── DivMediaPlayer.java │ │ │ ├── WinampMediaPlayer.java │ │ │ ├── ClientTestProgram.java │ │ │ └── interfacesegregation_principle_bad.ucls │ │ ├── singleresponsibility │ │ ├── bad │ │ │ ├── IUserService.java │ │ │ ├── singleresponsibility_principles_bad.png │ │ │ ├── User.java │ │ │ ├── UserService.java │ │ │ └── singleresponsibility_principles_bad.ucls │ │ └── good │ │ │ ├── IEmailService.java │ │ │ ├── IUserService.java │ │ │ ├── singleresponsibility_principles_good.png │ │ │ ├── UserService.java │ │ │ ├── User.java │ │ │ ├── EmailInfo.java │ │ │ ├── EmailService.java │ │ │ └── singleresponsibility_principles_good.ucls │ │ ├── openclosed │ │ ├── bad │ │ │ ├── openclosed_principle_bad.png │ │ │ ├── IConnectionProvider.java │ │ │ ├── ConnectionProvider.java │ │ │ └── openclosed_principle_bad.ucls │ │ └── good │ │ │ ├── openclosed_principle_good.png │ │ │ ├── IConnetionProvider.java │ │ │ ├── MySQLConnectionProvider.java │ │ │ ├── H2ConnectionProvider.java │ │ │ ├── OracleConnectionProvider.java │ │ │ ├── MsServerConnectionProvider.java │ │ │ └── openclosed_principle_good.ucls │ │ └── liskovssubstitution │ │ ├── bad │ │ ├── liskovssubstitution_principle_bad.png │ │ ├── VideoUnsupportedException.java │ │ ├── VlcMediaPlayer.java │ │ ├── DivMediaPlayer.java │ │ ├── MediaPlayer.java │ │ ├── WinampMediaPlayer.java │ │ ├── ClientTestProgram.java │ │ └── liskovssubstitution_principle_bad.ucls │ │ └── good │ │ ├── VideoUnsupportedException.java │ │ ├── AudioMediaPlayer.java │ │ ├── VlcMediaPlayer.java │ │ ├── DivMediaPlayer.java │ │ ├── MediaPlayer.java │ │ ├── VideoMediaPlayer.java │ │ ├── WinampMediaPlayer.java │ │ ├── ClientTestProgram.java │ │ └── liskovssubstitution_principle_good.ucls ├── .project ├── pom.xml └── .classpath ├── pom.xml └── README.md /oops-concepts/images/Cohesion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/Cohesion.png -------------------------------------------------------------------------------- /oops-concepts/images/coupling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/coupling.png -------------------------------------------------------------------------------- /oops-concepts/images/abstraction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/abstraction.png -------------------------------------------------------------------------------- /oops-concepts/images/aggregation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/aggregation.png -------------------------------------------------------------------------------- /oops-concepts/images/association.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/association.png -------------------------------------------------------------------------------- /oops-concepts/images/encapsulation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/encapsulation.png -------------------------------------------------------------------------------- /oops-concepts/images/runtime-poly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/runtime-poly.png -------------------------------------------------------------------------------- /oops-concepts/images/aggregation (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/aggregation (1).png -------------------------------------------------------------------------------- /oops-concepts/images/association (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/association (1).png -------------------------------------------------------------------------------- /oops-concepts/images/composition (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/composition (1).png -------------------------------------------------------------------------------- /oops-concepts/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /oops-concepts/images/Hybrid Inheritance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/Hybrid Inheritance.png -------------------------------------------------------------------------------- /oops-concepts/images/Single Inheritance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/Single Inheritance.png -------------------------------------------------------------------------------- /oops-concepts/images/multiple inheritance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/multiple inheritance.png -------------------------------------------------------------------------------- /oops-principles/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /oops-concepts/images/Multilevel Inheritance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/Multilevel Inheritance.png -------------------------------------------------------------------------------- /oops-concepts/images/inheritance-java-core.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/inheritance-java-core.png -------------------------------------------------------------------------------- /oops-concepts/images/Hierarchical Inheritance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/images/Hierarchical Inheritance.png -------------------------------------------------------------------------------- /oops-concepts/target/classes/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Built-By: RAMESH 3 | Build-Jdk: 1.8.0_151 4 | Created-By: Maven Integration for Eclipse 5 | 6 | -------------------------------------------------------------------------------- /oops-principles/target/classes/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Built-By: RAMESH 3 | Build-Jdk: 1.8.0_151 4 | Created-By: Maven Integration for Eclipse 5 | 6 | -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/inheritance/Dog.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/inheritance/Dog.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/abstraction/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/abstraction/Person.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/aggregation/Product.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/aggregation/Product.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/composition/Order.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/composition/Order.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/composition/Product.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/composition/Product.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/inheritance/Animal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/inheritance/Animal.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/Bike.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/Bike.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/Car.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/Car.class -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/MSServerConnection.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.good; 2 | 3 | public class MSServerConnection { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /oops-concepts/src/main/java/com/ramesh/ood/concepts/abstraction/Contractor.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/src/main/java/com/ramesh/ood/concepts/abstraction/Contractor.java -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/abstraction/Employee.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/abstraction/Employee.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/aggregation/LineItem.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/aggregation/LineItem.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/composition/LineItem.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/composition/LineItem.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/delegation/AirBooking.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/delegation/AirBooking.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/delegation/Delegation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/delegation/Delegation.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/encapsulation/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/encapsulation/Person.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/Vehicle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/Vehicle.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/polymorphism/Payment.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/polymorphism/Payment.class -------------------------------------------------------------------------------- /oops-concepts/src/main/java/com/ramesh/ood/concepts/polymorphism/Polymorphism.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/src/main/java/com/ramesh/ood/concepts/polymorphism/Polymorphism.java -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/abstraction/Abstraction.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/abstraction/Abstraction.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/abstraction/Contractor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/abstraction/Contractor.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/aggregation/Aggregation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/aggregation/Aggregation.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/composition/Composition.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/composition/Composition.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/delegation/TrainBooking.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/delegation/TrainBooking.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/delegation/TravelBooking.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/delegation/TravelBooking.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/inheritance/Inheritance.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/inheritance/Inheritance.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/polymorphism/CashPayment.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/polymorphism/CashPayment.class -------------------------------------------------------------------------------- /oops-concepts/src/main/java/com/ramesh/ood/concepts/abstraction/FullTimeEmployee.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/src/main/java/com/ramesh/ood/concepts/abstraction/FullTimeEmployee.java -------------------------------------------------------------------------------- /oops-concepts/src/main/java/com/ramesh/ood/concepts/loosecoupling/LooseCoupling.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/src/main/java/com/ramesh/ood/concepts/loosecoupling/LooseCoupling.java -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/BadTraveler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/BadTraveler.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/GoodTraveler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/GoodTraveler.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/polymorphism/CreditPayment.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/polymorphism/CreditPayment.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/polymorphism/Polymorphism.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/polymorphism/Polymorphism.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/abstraction/FullTimeEmployee.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/abstraction/FullTimeEmployee.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/encapsulation/Encapsulation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/encapsulation/Encapsulation.class -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/LooseCoupling.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/loosecoupling/LooseCoupling.class -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/README.md -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/README.md -------------------------------------------------------------------------------- /oops-concepts/target/classes/com/ramesh/ood/concepts/delegation/TicketBookingByAgent.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-concepts/target/classes/com/ramesh/ood/concepts/delegation/TicketBookingByAgent.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/App.class -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/bad/IUserService.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.singleresponsibility.bad; 2 | 3 | public interface IUserService { 4 | public void registerUser(User user); 5 | } 6 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/good/IEmailService.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.singleresponsibility.good; 2 | 3 | public interface IEmailService { 4 | void sendEmail(EmailInfo emailInfo); 5 | } -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/good/IUserService.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.singleresponsibility.good; 2 | 3 | public interface IUserService { 4 | public void registerUser(User user); 5 | } 6 | -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/App.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/bad/User.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/bad/User.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/User.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/User.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/Customer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/Customer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/CustomerDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/CustomerDao.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/DataSource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/DataSource.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/Customer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/Customer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/DataSource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/DataSource.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/MediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/MediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/openclosed/bad/ConnectionProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/openclosed/bad/ConnectionProvider.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/openclosed/bad/IConnectionProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/openclosed/bad/IConnectionProvider.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/IConnetionProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/IConnetionProvider.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/EmailInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/EmailInfo.class -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/bad/openclosed_principle_bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/bad/openclosed_principle_bad.png -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/CustomerDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/CustomerDao.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/H2DataSource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/H2DataSource.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/MediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/MediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/MediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/MediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/openclosed/bad/openclosed_principle_bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/openclosed/bad/openclosed_principle_bad.png -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/H2ConnectionProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/H2ConnectionProvider.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/bad/IUserService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/bad/IUserService.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/bad/UserService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/bad/UserService.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/UserService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/UserService.class -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/good/openclosed_principle_good.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/good/openclosed_principle_good.png -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/DatabaseConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/DatabaseConfig.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/MySQLDataSource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/MySQLDataSource.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/CustomerDaoImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/CustomerDaoImpl.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/DatabaseConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/DatabaseConfig.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/MySQLDataSource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/MySQLDataSource.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/DivMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/DivMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/VlcMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/VlcMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/DivMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/DivMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/VlcMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/VlcMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/DivMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/DivMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/VlcMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/VlcMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/DivMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/DivMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/VlcMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/VlcMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/MySQLConnectionProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/MySQLConnectionProvider.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/OracleConnectionProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/OracleConnectionProvider.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/openclosed_principle_good.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/openclosed_principle_good.png -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/bad/UserService$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/bad/UserService$1.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/EmailService$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/EmailService$1.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/EmailService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/EmailService.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/IEmailService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/IEmailService.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/IUserService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/IUserService.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/ClientTestProgram.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/ClientTestProgram.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/WinampMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/WinampMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/AudioMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/AudioMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/VideoMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/VideoMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/ClientTestProgram.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/ClientTestProgram.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/WinampMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/WinampMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/AudioMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/AudioMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/ClientTestProgram.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/ClientTestProgram.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/VideoMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/VideoMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/WinampMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/WinampMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/MsServerConnectionProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/openclosed/good/MsServerConnectionProvider.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/VoiletCustomerDaoImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/VoiletCustomerDaoImpl.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/MSServerConnection.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/MSServerConnection.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/ClientTestProgram.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/ClientTestProgram.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/WinampMediaPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/WinampMediaPlayer.class -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/good/IConnetionProvider.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.openclosed.good; 2 | 3 | import java.sql.Connection; 4 | 5 | public interface IConnetionProvider { 6 | public Connection establishconnection(); 7 | } 8 | -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/VideoUnsupportedException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/bad/VideoUnsupportedException.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/VideoUnsupportedException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/VideoUnsupportedException.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/VideoUnsupportedException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/good/VideoUnsupportedException.class -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/VideoUnsupportedException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/VideoUnsupportedException.class -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/bad/dependencyinversion_principles_bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/bad/dependencyinversion_principles_bad.png -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/bad/liskovssubstitution_principle_bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/bad/liskovssubstitution_principle_bad.png -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/liskovssubstitution_principle_bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/liskovssubstitution/bad/liskovssubstitution_principle_bad.png -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/dependencyinversion_principles_good.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/dependencyinversion_principles_good.png -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/bad/singleresponsibility_principles_bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/bad/singleresponsibility_principles_bad.png -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/dependencyinversion_principles_bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/bad/dependencyinversion_principles_bad.png -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/good/interfacesegregation_principle_good.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/good/interfacesegregation_principle_good.png -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/good/singleresponsibility_principles_good.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/good/singleresponsibility_principles_good.png -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/dependencyinversion_principles_good.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/dependencyinversion/good/dependencyinversion_principles_good.png -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/interfacesegregation_principle_good.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/interfacesegregation/good/interfacesegregation_principle_good.png -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/bad/singleresponsibility_principles_bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/bad/singleresponsibility_principles_bad.png -------------------------------------------------------------------------------- /oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/singleresponsibility_principles_good.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RameshMF/object-oriented-design/HEAD/oops-principles/target/classes/com/ramesh/ood/principles/singleresponsibility/good/singleresponsibility_principles_good.png -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/bad/VideoUnsupportedException.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.bad; 2 | 3 | public class VideoUnsupportedException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/bad/VideoUnsupportedException.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.bad; 2 | 3 | public class VideoUnsupportedException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/good/AudioMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.good; 2 | 3 | /** 4 | * Interface for playing audio. 5 | * 6 | */ 7 | public interface AudioMediaPlayer { 8 | public void playAudio(); 9 | } 10 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/good/VideoUnsupportedException.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.good; 2 | 3 | public class VideoUnsupportedException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/good/VideoUnsupportedException.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.good; 2 | 3 | public class VideoUnsupportedException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /oops-concepts/target/classes/META-INF/maven/com.ramesh.ood/oops-concepts/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven Integration for Eclipse 2 | #Sun Apr 08 10:51:53 IST 2018 3 | version=0.0.1-SNAPSHOT 4 | groupId=com.ramesh.ood 5 | m2e.projectName=ood-concepts 6 | m2e.projectLocation=E\:\\BLOGGER_WORK\\object-oriented-design\\oops-concepts 7 | artifactId=oops-concepts 8 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/good/VideoMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.good; 2 | 3 | /** 4 | * Interface for playing video. 5 | * 6 | */ 7 | public interface VideoMediaPlayer { 8 | 9 | // Play video implementation 10 | public void playVideo(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/good/AudioMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.good; 2 | 3 | /** 4 | * This class is getting ability of playing audio from its super class 5 | * 6 | * @author tirthalp 7 | */ 8 | public class AudioMediaPlayer extends MediaPlayer { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/bad/MediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.bad; 2 | 3 | /** 4 | * Interface for media player to play video and audio. 5 | * 6 | */ 7 | public interface MediaPlayer { 8 | public void playAudio(); 9 | public void playVideo(); 10 | 11 | } 12 | 13 | -------------------------------------------------------------------------------- /oops-principles/target/classes/META-INF/maven/com.ramesh.ood/oops-principles/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven Integration for Eclipse 2 | #Sun Apr 08 10:51:54 IST 2018 3 | version=0.0.1-SNAPSHOT 4 | groupId=com.ramesh.ood 5 | m2e.projectName=ood-principles 6 | m2e.projectLocation=E\:\\BLOGGER_WORK\\object-oriented-design\\oops-principles 7 | artifactId=oops-principles 8 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/bad/VlcMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.bad; 2 | 3 | /** 4 | * VLC Media player extending behavior of super class Media player. Perfect, LSP is not violated here. 5 | * 6 | * @author tirthalp 7 | */ 8 | public class VlcMediaPlayer extends MediaPlayer { 9 | 10 | } -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/bad/DataSource.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.bad; 2 | 3 | import java.sql.Connection; 4 | 5 | /** 6 | * Datasource interface 7 | * 8 | */ 9 | public interface DataSource { 10 | void createConnection(DatabaseConfig config); 11 | Connection getConnection(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/DataSource.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.good; 2 | 3 | import java.sql.Connection; 4 | 5 | /** 6 | * Datasource interface 7 | * 8 | */ 9 | public interface DataSource { 10 | void createConnection(DatabaseConfig config); 11 | Connection getConnection(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/bad/DivMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.bad; 2 | 3 | /** 4 | * Div Media player extending behavior of super class Media player. Perfect, LSP is not violated here. 5 | * 6 | * @author tirthalp 7 | */ 8 | public class DivMediaPlayer extends MediaPlayer { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/good/VlcMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.good; 2 | 3 | /** 4 | * VLC Media player extending behavior of super class Video Media Player. Perfect, LSP is not violated here. 5 | * 6 | * @author tirthalp 7 | */ 8 | public class VlcMediaPlayer extends VideoMediaPlayer { 9 | 10 | } -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/good/DivMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.good; 2 | 3 | /** 4 | * Div Media player extending behavior of super class Video Media Player. Perfect, LSP is not violated here. 5 | * 6 | * @author tirthalp 7 | */ 8 | public class DivMediaPlayer extends VideoMediaPlayer { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/good/MySQLConnectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.openclosed.good; 2 | 3 | import java.sql.Connection; 4 | 5 | public class MySQLConnectionProvider implements IConnetionProvider{ 6 | 7 | public Connection establishconnection() { 8 | // TODO : provide connection for MySQL database 9 | return null; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/good/H2ConnectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.openclosed.good; 2 | 3 | import java.sql.Connection; 4 | 5 | public class H2ConnectionProvider implements IConnetionProvider{ 6 | 7 | public Connection establishconnection() { 8 | // TODO : provide connection for H2 database and return the connection object 9 | return null; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/good/OracleConnectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.openclosed.good; 2 | 3 | import java.sql.Connection; 4 | 5 | public class OracleConnectionProvider implements IConnetionProvider{ 6 | 7 | public Connection establishconnection() { 8 | // TODO : provide connection for Oracle database and return the connection object 9 | return null; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/good/MediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.good; 2 | 3 | /** 4 | * Example media player super class which has ability to play audio 5 | * 6 | * @author tirthalp 7 | */ 8 | public class MediaPlayer { 9 | 10 | // Play audio implementation 11 | public void playAudio() { 12 | System.out.println("Playing audio..."); 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/bad/IConnectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.openclosed.bad; 2 | 3 | import java.sql.Connection; 4 | 5 | public interface IConnectionProvider { 6 | public Connection mysqlConnection(); 7 | public Connection msServerConnection(); 8 | public Connection h2Connection(); 9 | // if we need to support other database like oracle , we need to change this class 10 | } 11 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/good/MsServerConnectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.openclosed.good; 2 | 3 | import java.sql.Connection; 4 | 5 | public class MsServerConnectionProvider implements IConnetionProvider{ 6 | 7 | public Connection establishconnection() { 8 | // TODO : provide connection for MySQL database and return the connection object 9 | return null; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/good/WinampMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.good; 2 | 3 | /** 4 | * 5 | * So Winamp Media player only implements Audio Media Player. 6 | * 7 | */ 8 | public class WinampMediaPlayer implements AudioMediaPlayer { 9 | 10 | @Override 11 | public void playAudio() { 12 | System.out.println(" Playing audio........"); 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /oops-concepts/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.ramesh.ood 5 | object-oriented-design 6 | 0.0.1-SNAPSHOT 7 | 8 | oops-concepts 9 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/good/VideoMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.good; 2 | 3 | /** 4 | * This class has ability to play video as well as getting audio ability from super class 5 | * 6 | * @author tirthalp 7 | */ 8 | public class VideoMediaPlayer extends MediaPlayer { 9 | 10 | // Play video implementation 11 | public void playVideo() { 12 | System.out.println("Playing video..."); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /oops-concepts/target/classes/META-INF/maven/com.ramesh.ood/oops-concepts/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.ramesh.ood 5 | object-oriented-design 6 | 0.0.1-SNAPSHOT 7 | 8 | oops-concepts 9 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/good/WinampMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.good; 2 | 3 | /** 4 | * Now there is a need of launching new Winamp player to play audio, but playing video is not supported at this stage. 5 | * 6 | * So Winamp Media player extending behavior of super class Audio Media Player. Perfect, LSP is not violated here. 7 | * 8 | * @author tirthalp 9 | */ 10 | public class WinampMediaPlayer extends AudioMediaPlayer { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | com.ramesh.ood 4 | object-oriented-design 5 | 0.0.1-SNAPSHOT 6 | pom 7 | 8 | oops-concepts 9 | oops-principles 10 | 11 | -------------------------------------------------------------------------------- /oops-concepts/images/Hybrid Inheritance.xml: -------------------------------------------------------------------------------- 1 | ddHBEoIgEADQr+GOMKV3s7p08tCZAJUJXQdxtL4+DcwYiwMDb3dZBhBN6/FkWFtdQEiNCBYjogdESJzsp3mGhwO6jx2URglH0Qq5ekqP2GuvhOyCRAugrWpD5NA0ktvAmDEwhGkF6LBry0q5gZwzvdWrErZymuzw6mepymrpHGEfuTF+Lw30je+HCC3ew4Vrtpzl87uKCRi+iGaIpgbAulU9plLPT7s8m6s7/ol+7m1kY38UTIv17GkT/B/NXg== -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/good/DivMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.good; 2 | 3 | /** 4 | * Div Media player implements both VideoMediaPlayer,AudioMediaPlayer. 5 | */ 6 | public class DivMediaPlayer implements VideoMediaPlayer, AudioMediaPlayer { 7 | 8 | @Override 9 | public void playVideo() { 10 | System.out.println(" Playing video .........."); 11 | 12 | } 13 | 14 | @Override 15 | public void playAudio() { 16 | System.out.println(" Playing audio .........."); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/bad/MediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.bad; 2 | 3 | /** 4 | * Example media player super class which has ability to play video and audio 5 | * 6 | * @author tirthalp 7 | */ 8 | public class MediaPlayer { 9 | 10 | // Play audio implementation 11 | public void playAudio() { 12 | System.out.println("Playing audio..."); 13 | } 14 | 15 | // Play video implementation 16 | public void playVideo() { 17 | System.out.println("Playing video..."); 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/good/UserService.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.singleresponsibility.good; 2 | 3 | public class UserService implements IUserService { 4 | 5 | private EmailInfo emailInfo; 6 | private IEmailService emailService; 7 | public void registerUser(User user) { 8 | // save user to database 9 | // send mail to user for verification. 10 | 11 | emailInfo = new EmailInfo("some subject", "some body", user.getEmail()); 12 | emailService = new EmailService(); 13 | emailService.sendEmail(emailInfo); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/bad/VlcMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.bad; 2 | 3 | /** 4 | * VLC Media player implements Media player. 5 | * Perfect, LSP is not violated here. 6 | * 7 | * @author tirthalp 8 | */ 9 | public class VlcMediaPlayer implements MediaPlayer { 10 | @Override 11 | public void playAudio() { 12 | System.out.println(" Playing audio .........."); 13 | 14 | } 15 | 16 | @Override 17 | public void playVideo() { 18 | System.out.println(" Playing video .........."); 19 | 20 | } 21 | } -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/bad/DivMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.bad; 2 | 3 | /** 4 | * Div Media player implements Media player. Perfect, 5 | * LSP is not violated here. 6 | * 7 | * @author tirthalp 8 | */ 9 | public class DivMediaPlayer implements MediaPlayer { 10 | 11 | @Override 12 | public void playAudio() { 13 | System.out.println(" Playing audio .........."); 14 | 15 | } 16 | 17 | @Override 18 | public void playVideo() { 19 | System.out.println(" Playing video .........."); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /oops-concepts/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ood-concepts 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /oops-principles/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ood-principles 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/good/VlcMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.good; 2 | 3 | /** 4 | * VLC Media player implements both Video Media Player and Audio Media Player. 5 | * Perfect, LSP is not violated here. 6 | * 7 | * @author tirthalp 8 | */ 9 | public class VlcMediaPlayer implements VideoMediaPlayer, AudioMediaPlayer { 10 | 11 | @Override 12 | public void playVideo() { 13 | System.out.println(" Playing video .........."); 14 | 15 | } 16 | 17 | @Override 18 | public void playAudio() { 19 | System.out.println(" Playing audio .........."); 20 | 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/bad/ConnectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.openclosed.bad; 2 | 3 | import java.sql.Connection; 4 | 5 | public class ConnectionProvider implements IConnectionProvider{ 6 | 7 | public Connection mysqlConnection() { 8 | // establish connection to MySQL database 9 | return null; 10 | } 11 | 12 | public Connection msServerConnection() { 13 | // TODO establish connection to ms-server database 14 | return null; 15 | } 16 | 17 | public Connection h2Connection() { 18 | // establish connection to h2 database 19 | return null; 20 | } 21 | 22 | // if we need to support other database like oracle , we need to change this class 23 | } 24 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/bad/User.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.singleresponsibility.bad; 2 | 3 | public class User { 4 | private String firstName; 5 | private String lastName; 6 | private String email; 7 | public String getFirstName() { 8 | return firstName; 9 | } 10 | public void setFirstName(String firstName) { 11 | this.firstName = firstName; 12 | } 13 | public String getLastName() { 14 | return lastName; 15 | } 16 | public void setLastName(String lastName) { 17 | this.lastName = lastName; 18 | } 19 | public String getEmail() { 20 | return email; 21 | } 22 | public void setEmail(String email) { 23 | this.email = email; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/good/User.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.singleresponsibility.good; 2 | 3 | public class User { 4 | private String firstName; 5 | private String lastName; 6 | private String email; 7 | public String getFirstName() { 8 | return firstName; 9 | } 10 | public void setFirstName(String firstName) { 11 | this.firstName = firstName; 12 | } 13 | public String getLastName() { 14 | return lastName; 15 | } 16 | public void setLastName(String lastName) { 17 | this.lastName = lastName; 18 | } 19 | public String getEmail() { 20 | return email; 21 | } 22 | public void setEmail(String email) { 23 | this.email = email; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/bad/WinampMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.bad; 2 | 3 | /** 4 | * Now there is a need of launching new Winamp player to play audio, but playing video is not supported at this stage. 5 | * 6 | * Oops... LSP is violated here! Why? Logically winamp player only supports playing audio. So what's wrong in overriding playVideo method of super class? 7 | * 8 | * Well, see how it broke the client program (ClientTestProgram.java) 9 | * 10 | * @author tirthalp 11 | */ 12 | public class WinampMediaPlayer extends MediaPlayer { 13 | 14 | // Play video is not supported in Winamp player 15 | public void playVideo() { 16 | throw new VideoUnsupportedException(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /oops-concepts/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.8 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 13 | org.eclipse.jdt.core.compiler.source=1.5 14 | -------------------------------------------------------------------------------- /oops-principles/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.7 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 13 | org.eclipse.jdt.core.compiler.source=1.7 14 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/bad/WinampMediaPlayer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.bad; 2 | 3 | /** 4 | * Now there is a need of launching new Winamp player to play audio, 5 | * but playing video is not supported at this stage. 6 | * 7 | * Here , clients should not be forced to depend upon interface members they do not use. 8 | * In this case , playVideo() method is not required 9 | * 10 | */ 11 | public class WinampMediaPlayer implements MediaPlayer { 12 | 13 | // Play video is not supported in Winamp player 14 | public void playVideo() { 15 | throw new VideoUnsupportedException(); 16 | } 17 | 18 | @Override 19 | public void playAudio() { 20 | System.out.println("Playing audio .............."); 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/good/EmailInfo.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.singleresponsibility.good; 2 | 3 | public class EmailInfo { 4 | private String subject; 5 | private String body; 6 | private String email; 7 | public EmailInfo(String subject, String body, String email) { 8 | super(); 9 | this.subject = subject; 10 | this.body = body; 11 | this.email = email; 12 | } 13 | // add required fields for advanced mailing... 14 | public String getSubject() { 15 | return subject; 16 | } 17 | public void setSubject(String subject) { 18 | this.subject = subject; 19 | } 20 | public String getBody() { 21 | return body; 22 | } 23 | public void setBody(String body) { 24 | this.body = body; 25 | } 26 | public String getEmail() { 27 | return email; 28 | } 29 | public void setEmail(String email) { 30 | this.email = email; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/bad/DatabaseConfig.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.bad; 2 | 3 | public class DatabaseConfig { 4 | private String driverClass; 5 | private String userName; 6 | private String password; 7 | private String url; 8 | public String getDriverClass() { 9 | return driverClass; 10 | } 11 | public void setDriverClass(String driverClass) { 12 | this.driverClass = driverClass; 13 | } 14 | public String getUserName() { 15 | return userName; 16 | } 17 | public void setUserName(String userName) { 18 | this.userName = userName; 19 | } 20 | public String getPassword() { 21 | return password; 22 | } 23 | public void setPassword(String password) { 24 | this.password = password; 25 | } 26 | public String getUrl() { 27 | return url; 28 | } 29 | public void setUrl(String url) { 30 | this.url = url; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/DatabaseConfig.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.good; 2 | 3 | public class DatabaseConfig { 4 | private String driverClass; 5 | private String userName; 6 | private String password; 7 | private String url; 8 | public String getDriverClass() { 9 | return driverClass; 10 | } 11 | public void setDriverClass(String driverClass) { 12 | this.driverClass = driverClass; 13 | } 14 | public String getUserName() { 15 | return userName; 16 | } 17 | public void setUserName(String userName) { 18 | this.userName = userName; 19 | } 20 | public String getPassword() { 21 | return password; 22 | } 23 | public void setPassword(String password) { 24 | this.password = password; 25 | } 26 | public String getUrl() { 27 | return url; 28 | } 29 | public void setUrl(String url) { 30 | this.url = url; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/H2DataSource.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.good; 2 | 3 | import java.sql.Connection; 4 | import java.sql.SQLException; 5 | 6 | import org.h2.jdbcx.JdbcDataSource; 7 | 8 | public class H2DataSource implements DataSource { 9 | 10 | private JdbcDataSource dataSource; 11 | 12 | @Override 13 | public void createConnection(DatabaseConfig databaseConfig) { 14 | dataSource = new JdbcDataSource(); 15 | dataSource.setURL(databaseConfig.getUrl()); 16 | dataSource.setUser(databaseConfig.getUserName()); 17 | dataSource.setPassword(databaseConfig.getPassword()); 18 | } 19 | 20 | @Override 21 | public Connection getConnection() { 22 | try { 23 | return dataSource.getConnection(); 24 | } catch (SQLException e) { 25 | // TODO Auto-generated catch block 26 | e.printStackTrace(); 27 | } 28 | return null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/MySQLDataSource.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.good; 2 | 3 | import java.sql.Connection; 4 | import java.sql.SQLException; 5 | 6 | import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; 7 | 8 | public class MySQLDataSource implements DataSource { 9 | 10 | private MysqlDataSource dataSource; 11 | 12 | @Override 13 | public void createConnection(DatabaseConfig databaseConfig) { 14 | dataSource = new MysqlDataSource(); 15 | dataSource.setUrl(databaseConfig.getUrl()); 16 | dataSource.setUser(databaseConfig.getUserName()); 17 | dataSource.setPassword(databaseConfig.getPassword()); 18 | } 19 | 20 | @Override 21 | public Connection getConnection() { 22 | try { 23 | return dataSource.getConnection(); 24 | } catch (SQLException e) { 25 | // TODO Auto-generated catch block 26 | e.printStackTrace(); 27 | } 28 | return null; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /oops-concepts/src/main/java/com/ramesh/ood/concepts/abstraction/Employee.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.concepts.abstraction; 2 | 3 | /** 4 | * Lets first create the superclass Employee. Note the usage of abstract keyword in class definition. This marks the class to be abstract, which means it can not be instantiated directly. We define a method called calculateSalary() as an abstract method. This way you leave the implementation of this method to the inheritors of the Employee class. 5 | * @author RAMESH 6 | * 7 | */ 8 | public abstract class Employee { 9 | 10 | private String name; 11 | private int paymentPerHour; 12 | 13 | public Employee(String name, int paymentPerHour) { 14 | this.name = name; 15 | this.paymentPerHour = paymentPerHour; 16 | } 17 | 18 | public abstract int calculateSalary(); 19 | public String getName() { 20 | return name; 21 | } 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | public int getPaymentPerHour() { 26 | return paymentPerHour; 27 | } 28 | public void setPaymentPerHour(int paymentPerHour) { 29 | this.paymentPerHour = paymentPerHour; 30 | } 31 | } -------------------------------------------------------------------------------- /oops-principles/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.ramesh.ood 6 | object-oriented-design 7 | 0.0.1-SNAPSHOT 8 | 9 | oops-principles 10 | 11 | 12 | 13 | com.sun.mail 14 | javax.mail 15 | 1.5.5 16 | 17 | 18 | 19 | 20 | com.h2database 21 | h2 22 | 1.0.60 23 | test 24 | 25 | 26 | 27 | 28 | mysql 29 | mysql-connector-java 30 | 5.1.6 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /oops-principles/target/classes/META-INF/maven/com.ramesh.ood/oops-principles/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.ramesh.ood 6 | object-oriented-design 7 | 0.0.1-SNAPSHOT 8 | 9 | oops-principles 10 | 11 | 12 | 13 | com.sun.mail 14 | javax.mail 15 | 1.5.5 16 | 17 | 18 | 19 | 20 | com.h2database 21 | h2 22 | 1.0.60 23 | test 24 | 25 | 26 | 27 | 28 | mysql 29 | mysql-connector-java 30 | 5.1.6 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/bad/CustomerDao.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.bad; 2 | 3 | public interface CustomerDao { 4 | /** 5 | * @param id unique identifier of the customer. 6 | * @return an optional with customer if a customer with unique identifier id 7 | * exists, empty optional otherwise. 8 | * @throws Exception if any error occurs. 9 | */ 10 | Customer getById(int id) throws Exception; 11 | 12 | /** 13 | * @param customer the customer to be added. 14 | * @return true if customer is successfully added, false if customer already exists. 15 | * @throws Exception if any error occurs. 16 | */ 17 | boolean add(Customer customer) throws Exception; 18 | 19 | /** 20 | * @param customer the customer to be updated. 21 | * @return true if customer exists and is successfully updated, false otherwise. 22 | * @throws Exception if any error occurs. 23 | */ 24 | boolean update(Customer customer) throws Exception; 25 | 26 | /** 27 | * @param customer the customer to be deleted. 28 | * @return true if customer exists and is successfully deleted, false otherwise. 29 | * @throws Exception if any error occurs. 30 | */ 31 | boolean delete(Customer customer) throws Exception; 32 | } 33 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/CustomerDao.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.good; 2 | 3 | public interface CustomerDao { 4 | /** 5 | * @param id unique identifier of the customer. 6 | * @return an optional with customer if a customer with unique identifier id 7 | * exists, empty optional otherwise. 8 | * @throws Exception if any error occurs. 9 | */ 10 | Customer getById(int id) throws Exception; 11 | 12 | /** 13 | * @param customer the customer to be added. 14 | * @return true if customer is successfully added, false if customer already exists. 15 | * @throws Exception if any error occurs. 16 | */ 17 | boolean add(Customer customer) throws Exception; 18 | 19 | /** 20 | * @param customer the customer to be updated. 21 | * @return true if customer exists and is successfully updated, false otherwise. 22 | * @throws Exception if any error occurs. 23 | */ 24 | boolean update(Customer customer) throws Exception; 25 | 26 | /** 27 | * @param customer the customer to be deleted. 28 | * @return true if customer exists and is successfully deleted, false otherwise. 29 | * @throws Exception if any error occurs. 30 | */ 31 | boolean delete(Customer customer) throws Exception; 32 | } 33 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/bad/MySQLDataSource.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.bad; 2 | 3 | import java.sql.Connection; 4 | import java.sql.SQLException; 5 | 6 | import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; 7 | 8 | public class MySQLDataSource implements DataSource { 9 | 10 | private MysqlDataSource dataSource; 11 | private static DatabaseConfig config; 12 | public MySQLDataSource(){ 13 | config = new DatabaseConfig(); 14 | config.setDriverClass("com.mysql.jdbc.Driver"); 15 | config.setUrl("jdbc:mysql://localhost:3306/demo"); 16 | config.setUserName("root"); 17 | config.setPassword("root"); 18 | DataSource dataSource = new MySQLDataSource(); 19 | dataSource.createConnection(config); 20 | } 21 | 22 | @Override 23 | public void createConnection(DatabaseConfig databaseConfig) { 24 | dataSource = new MysqlDataSource(); 25 | dataSource.setUrl(databaseConfig.getUrl()); 26 | dataSource.setUser(databaseConfig.getUserName()); 27 | dataSource.setPassword(databaseConfig.getPassword()); 28 | } 29 | 30 | @Override 31 | public Connection getConnection() { 32 | try { 33 | return dataSource.getConnection(); 34 | } catch (SQLException e) { 35 | // TODO Auto-generated catch block 36 | e.printStackTrace(); 37 | } 38 | return null; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/good/ClientTestProgram.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.good; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * This is sample client program which refers MediaPlayer 8 | * 9 | * @author tirthalp 10 | */ 11 | public class ClientTestProgram { 12 | 13 | public static void main(String[] args) { 14 | 15 | // Created list of video players 16 | List allPlayers = new ArrayList(); 17 | allPlayers.add(new VlcMediaPlayer()); 18 | allPlayers.add(new DivMediaPlayer()); 19 | 20 | // Play video in all players 21 | playVideoInAllMediaPlayers(allPlayers); 22 | 23 | // Well - all works as of now...... :-) 24 | System.out.println("---------------------------"); 25 | 26 | // Now adding new Winamp player. If you uncomment below line, it would give compile time error as can't add audio player in list of video players. 27 | // allPlayers.add(new WinampMediaPlayer()); 28 | } 29 | 30 | /** 31 | * This method is playing video in all players 32 | * 33 | * @param allPlayers 34 | */ 35 | public static void playVideoInAllMediaPlayers(List allPlayers) { 36 | 37 | for(VideoMediaPlayer player : allPlayers) { 38 | player.playVideo(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/good/ClientTestProgram.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.good; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * This is sample client program which refers MediaPlayer 8 | * 9 | * @author tirthalp 10 | */ 11 | public class ClientTestProgram { 12 | 13 | public static void main(String[] args) { 14 | 15 | // Created list of video players 16 | List allPlayers = new ArrayList(); 17 | allPlayers.add(new VlcMediaPlayer()); 18 | allPlayers.add(new DivMediaPlayer()); 19 | 20 | // Play video in all players 21 | playVideoInAllMediaPlayers(allPlayers); 22 | 23 | // Well - all works as of now...... :-) 24 | System.out.println("---------------------------"); 25 | 26 | // Now adding new Winamp player. If you uncomment below line, it would give compile time error as can't add audio player in list of video players. 27 | // allPlayers.add(new WinampMediaPlayer()); 28 | } 29 | 30 | /** 31 | * This method is playing video in all players 32 | * 33 | * @param allPlayers 34 | */ 35 | public static void playVideoInAllMediaPlayers(List allPlayers) { 36 | 37 | for(VideoMediaPlayer player : allPlayers) { 38 | player.playVideo(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/bad/ClientTestProgram.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.liskovssubstitution.bad; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * This is sample client program which refers MediaPlayer 8 | * 9 | * @author tirthalp 10 | */ 11 | public class ClientTestProgram { 12 | 13 | public static void main(String[] args) { 14 | 15 | // Created list of players 16 | List allPlayers = new ArrayList(); 17 | allPlayers.add(new VlcMediaPlayer()); 18 | allPlayers.add(new DivMediaPlayer()); 19 | 20 | // Play video in all players 21 | playVideoInAllMediaPlayers(allPlayers); 22 | 23 | // Well - all works as of now...... :-) 24 | System.out.println("---------------------------"); 25 | 26 | // Now adding new Winamp player 27 | allPlayers.add(new WinampMediaPlayer()); 28 | 29 | // Again play video in all players & Oops it broke the program... :-( 30 | // Why we got unexpected behavior in client? --- Because LSP is violated in WinampMediaPlayer.java, as it changed the original behavior of super class MediaPlayer.java 31 | playVideoInAllMediaPlayers(allPlayers); 32 | } 33 | 34 | /** 35 | * This method is playing video in all players 36 | * 37 | * @param allPlayers 38 | */ 39 | public static void playVideoInAllMediaPlayers(List allPlayers) { 40 | 41 | for(MediaPlayer player : allPlayers) { 42 | player.playVideo(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/bad/ClientTestProgram.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.interfacesegregation.bad; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * This is sample client program which refers MediaPlayer 8 | * 9 | * @author tirthalp 10 | */ 11 | public class ClientTestProgram { 12 | 13 | public static void main(String[] args) { 14 | 15 | // Created list of players 16 | List allPlayers = new ArrayList(); 17 | allPlayers.add(new VlcMediaPlayer()); 18 | allPlayers.add(new DivMediaPlayer()); 19 | 20 | // Play video in all players 21 | playVideoInAllMediaPlayers(allPlayers); 22 | 23 | // Well - all works as of now...... :-) 24 | System.out.println("---------------------------"); 25 | 26 | // Now adding new Winamp player 27 | allPlayers.add(new WinampMediaPlayer()); 28 | 29 | // Again play video in all players & Oops it broke the program... :-( 30 | // Why we got unexpected behavior in client? --- Because LSP is violated in WinampMediaPlayer.java, as it changed the original behavior of super class MediaPlayer.java 31 | playVideoInAllMediaPlayers(allPlayers); 32 | } 33 | 34 | /** 35 | * This method is playing video in all players 36 | * 37 | * @param allPlayers 38 | */ 39 | public static void playVideoInAllMediaPlayers(List allPlayers) { 40 | 41 | for(MediaPlayer player : allPlayers) { 42 | player.playVideo(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/bad/App.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.bad; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class App { 7 | 8 | public static void main(String[] args) throws Exception { 9 | 10 | CustomerDao customerDao = new VoiletCustomerDaoImpl(); 11 | performOperationsUsing(customerDao); 12 | } 13 | 14 | private static void addCustomers(CustomerDao customerDao) throws Exception { 15 | for (Customer customer : generateSampleCustomers()) { 16 | customerDao.add(customer); 17 | } 18 | } 19 | 20 | private static void performOperationsUsing(final CustomerDao customerDao) throws Exception { 21 | addCustomers(customerDao); 22 | final Customer customer = new Customer(4, "Dan", "Danson"); 23 | customerDao.add(customer); 24 | customer.setFirstName("Daniel"); 25 | customer.setLastName("Danielson"); 26 | customerDao.update(customer); 27 | } 28 | 29 | /** 30 | * Generate customers. 31 | * 32 | * @return list of customers. 33 | */ 34 | public static List generateSampleCustomers() { 35 | final Customer customer1 = new Customer(1, "Adam", "Adamson"); 36 | final Customer customer2 = new Customer(2, "Bob", "Bobson"); 37 | final Customer customer3 = new Customer(3, "Carl", "Carlson"); 38 | final List customers = new ArrayList(); 39 | customers.add(customer1); 40 | customers.add(customer2); 41 | customers.add(customer3); 42 | return customers; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /oops-concepts/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /oops-principles/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/bad/Customer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.bad; 2 | 3 | /** 4 | * A customer POJO that represents the data that will be read from the data source. 5 | * 6 | */ 7 | public class Customer { 8 | 9 | private int id; 10 | private String firstName; 11 | private String lastName; 12 | 13 | /** 14 | * Creates an instance of customer. 15 | */ 16 | public Customer(final int id, final String firstName, final String lastName) { 17 | this.id = id; 18 | this.firstName = firstName; 19 | this.lastName = lastName; 20 | } 21 | 22 | public int getId() { 23 | return id; 24 | } 25 | 26 | public void setId(final int id) { 27 | this.id = id; 28 | } 29 | 30 | public String getFirstName() { 31 | return firstName; 32 | } 33 | 34 | public void setFirstName(final String firstName) { 35 | this.firstName = firstName; 36 | } 37 | 38 | public String getLastName() { 39 | return lastName; 40 | } 41 | 42 | public void setLastName(final String lastName) { 43 | this.lastName = lastName; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "Customer{" + "id=" + getId() + ", firstName='" + getFirstName() + '\'' + ", lastName='" 49 | + getLastName() + '\'' + '}'; 50 | } 51 | 52 | @Override 53 | public boolean equals(final Object that) { 54 | boolean isEqual = false; 55 | if (this == that) { 56 | isEqual = true; 57 | } else if (that != null && getClass() == that.getClass()) { 58 | final Customer customer = (Customer) that; 59 | if (getId() == customer.getId()) { 60 | isEqual = true; 61 | } 62 | } 63 | return isEqual; 64 | } 65 | 66 | @Override 67 | public int hashCode() { 68 | return getId(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/Customer.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.good; 2 | 3 | /** 4 | * A customer POJO that represents the data that will be read from the data source. 5 | * 6 | */ 7 | public class Customer { 8 | 9 | private int id; 10 | private String firstName; 11 | private String lastName; 12 | 13 | /** 14 | * Creates an instance of customer. 15 | */ 16 | public Customer(final int id, final String firstName, final String lastName) { 17 | this.id = id; 18 | this.firstName = firstName; 19 | this.lastName = lastName; 20 | } 21 | 22 | public int getId() { 23 | return id; 24 | } 25 | 26 | public void setId(final int id) { 27 | this.id = id; 28 | } 29 | 30 | public String getFirstName() { 31 | return firstName; 32 | } 33 | 34 | public void setFirstName(final String firstName) { 35 | this.firstName = firstName; 36 | } 37 | 38 | public String getLastName() { 39 | return lastName; 40 | } 41 | 42 | public void setLastName(final String lastName) { 43 | this.lastName = lastName; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "Customer{" + "id=" + getId() + ", firstName='" + getFirstName() + '\'' + ", lastName='" 49 | + getLastName() + '\'' + '}'; 50 | } 51 | 52 | @Override 53 | public boolean equals(final Object that) { 54 | boolean isEqual = false; 55 | if (this == that) { 56 | isEqual = true; 57 | } else if (that != null && getClass() == that.getClass()) { 58 | final Customer customer = (Customer) that; 59 | if (getId() == customer.getId()) { 60 | isEqual = true; 61 | } 62 | } 63 | return isEqual; 64 | } 65 | 66 | @Override 67 | public int hashCode() { 68 | return getId(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /oops-concepts/src/main/java/com/ramesh/ood/concepts/inheritance/Inheritance.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.concepts.inheritance; 2 | 3 | //--------------------------------------- 4 | //--- STEP 00 - WHAT IS INHERITANCE? 5 | //--------------------------------------- 6 | 7 | ///** 8 | // * Inheritance = is-a relationship between a superclass and its subclasses. 9 | // * 10 | // * For example, Dog (subclass) is-a of type Animal (superclass). So Dog can inherit (reuse) members of Animal class; 11 | // * plus it can have its own new behavior and properties. 12 | // */ 13 | 14 | //--------------------------------------- 15 | //--- STEP 01 - UNDERSTAND INHERITANCE BY EXAMPLE 16 | //--------------------------------------- 17 | 18 | /** 19 | * Test class for inheritance behavior - Dog class is inheriting behavior and properties of Animal class and can have its own too. 20 | * 21 | * 22 | */ 23 | public class Inheritance { 24 | 25 | public static void main(String[] args) { 26 | Dog dog = new Dog(); 27 | dog.setId(123); // inherited from super class 28 | dog.sound(); // overrided behavior of sub class 29 | } 30 | } 31 | 32 | /** 33 | * This is parent (also called as super or base) class Animal 34 | * 35 | * @author tirthalp 36 | * 37 | */ 38 | class Animal { 39 | int id; 40 | 41 | public int getId() { 42 | return id; 43 | } 44 | 45 | public void setId(int id) { 46 | this.id = id; 47 | } 48 | 49 | public void sound() { 50 | System.out.println("By default it is mute"); 51 | } 52 | } 53 | 54 | /** 55 | * This is subclass (also called as derived or child or extended) Dog which is extending Animal 56 | * 57 | * @author tirthalp 58 | * 59 | */ 60 | class Dog extends Animal { 61 | 62 | // Own behavior 63 | private void bark() { 64 | System.out.println("Dog '" + getId() + "' is barking"); 65 | } 66 | 67 | // Overriding super class behavior 68 | @Override 69 | public void sound() { 70 | bark(); 71 | } 72 | } -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/bad/openclosed_principle_bad.ucls: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/good/EmailService.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.singleresponsibility.good; 2 | 3 | import java.util.Date; 4 | import java.util.Properties; 5 | 6 | import javax.mail.Authenticator; 7 | import javax.mail.Message; 8 | import javax.mail.PasswordAuthentication; 9 | import javax.mail.Session; 10 | import javax.mail.Transport; 11 | import javax.mail.internet.InternetAddress; 12 | import javax.mail.internet.MimeMessage; 13 | 14 | public class EmailService implements IEmailService { 15 | 16 | private final static String password = "mypassword"; // correct password for gmail id 17 | private final static String fromEmail = "myemail@yahoo.com"; // can be any email id 18 | public void sendEmail(EmailInfo emailInfo) { 19 | 20 | Properties props = new Properties(); 21 | props.put("mail.smtp.host", "smtp.gmail.com"); // SMTP Host 22 | props.put("mail.smtp.port", "587"); // TLS Port 23 | props.put("mail.smtp.auth", "true"); // enable authentication 24 | props.put("mail.smtp.starttls.enable", "true"); // enable STARTTLS 25 | 26 | // create Authenticator object to pass in Session.getInstance argument 27 | Authenticator auth = new Authenticator() { 28 | // override the getPasswordAuthentication method 29 | protected PasswordAuthentication getPasswordAuthentication() { 30 | return new PasswordAuthentication(fromEmail, password); 31 | } 32 | }; 33 | Session session = Session.getInstance(props, auth); 34 | sendEmail(session, emailInfo.getEmail(), emailInfo.getSubject(), emailInfo.getBody()); 35 | 36 | } 37 | 38 | private void sendEmail(Session session, String toEmail, String subject, String body) { 39 | try { 40 | MimeMessage msg = new MimeMessage(session); 41 | // set message headers 42 | msg.addHeader("Content-type", "text/HTML; charset=UTF-8"); 43 | msg.addHeader("format", "flowed"); 44 | msg.addHeader("Content-Transfer-Encoding", "8bit"); 45 | 46 | msg.setFrom(new InternetAddress("no_reply@gmail.com", "NoReply-JD")); 47 | 48 | msg.setReplyTo(InternetAddress.parse("no_reply@gmail.com", false)); 49 | 50 | msg.setSubject(subject, "UTF-8"); 51 | 52 | msg.setText(body, "UTF-8"); 53 | 54 | msg.setSentDate(new Date()); 55 | 56 | msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toEmail, false)); 57 | System.out.println("Message is ready"); 58 | Transport.send(msg); 59 | 60 | System.out.println("EMail Sent Successfully!!"); 61 | } catch (Exception e) { 62 | e.printStackTrace(); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /oops-concepts/src/main/java/com/ramesh/ood/concepts/delegation/Delegation.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.concepts.delegation; 2 | 3 | //--------------------------------------- 4 | //--- STEP 00 - WHAT IS DELEGATION? 5 | //--------------------------------------- 6 | 7 | ///** 8 | // * Delegation = hand over the responsibility for a particular task to another class or method. 9 | // * 10 | // * If you need to use functionality in another class but you do not want to change that functionality then use delegation instead of inheritance. 11 | // */ 12 | 13 | //--------------------------------------- 14 | //--- STEP 01 - UNDERSTAND DELEGATION (ALONG WITH POLYMORPHISM) BY EXAMPLE 15 | //--------------------------------------- 16 | 17 | /** 18 | * This is test class for the delegation and polymorphism example 19 | * 20 | * 21 | */ 22 | public class Delegation { 23 | 24 | public static void main(String[] args) { 25 | // Here TicketBookingByAgent class is internally delegating train ticket booking responsibility to other class 26 | TicketBookingByAgent agent = new TicketBookingByAgent(new TrainBooking()); 27 | agent.bookTicket(); 28 | 29 | // Here TicketBookingByAgent class is internally delegating airline ticket booking responsibility to other class 30 | agent = new TicketBookingByAgent(new AirBooking()); 31 | agent.bookTicket(); 32 | } 33 | } 34 | 35 | /** 36 | * TicketBokkingByAgent provides implementation of TravelBooking. But it delegates actual ticket booking to other class at runtime using Polymorphism. 37 | * 38 | * @author tirthalp 39 | * 40 | */ 41 | class TicketBookingByAgent implements TravelBooking { 42 | 43 | TravelBooking t; 44 | 45 | public TicketBookingByAgent(TravelBooking t) { 46 | this.t = t; 47 | } 48 | 49 | // Delegation --- Here ticket booking responsibility is delegated to other class using polymorphism 50 | @Override 51 | public void bookTicket() { 52 | t.bookTicket(); 53 | } 54 | } 55 | 56 | /** 57 | * This represents TravelBooking interface 58 | * 59 | * @author tirthalp 60 | * 61 | */ 62 | interface TravelBooking { 63 | public void bookTicket(); 64 | } 65 | 66 | /** 67 | * TrainBooking IS-A TravelBooking type 68 | * 69 | * @author tirthalp 70 | * 71 | */ 72 | class TrainBooking implements TravelBooking { 73 | @Override 74 | public void bookTicket() { 75 | System.out.println("Train ticket booked"); 76 | } 77 | } 78 | 79 | /** 80 | * AirBooking IS-A TravelBooking type 81 | * 82 | * @author tirthalp 83 | * 84 | */ 85 | class AirBooking implements TravelBooking { 86 | @Override 87 | public void bookTicket() { 88 | System.out.println("Flight ticket booked"); 89 | } 90 | } -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/bad/UserService.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.singleresponsibility.bad; 2 | 3 | import java.util.Date; 4 | import java.util.Properties; 5 | 6 | import javax.mail.Authenticator; 7 | import javax.mail.Message; 8 | import javax.mail.PasswordAuthentication; 9 | import javax.mail.Session; 10 | import javax.mail.Transport; 11 | import javax.mail.internet.InternetAddress; 12 | import javax.mail.internet.MimeMessage; 13 | 14 | public class UserService implements IUserService { 15 | 16 | public void registerUser(User user) { 17 | // save user to database 18 | // send mail to user for verfication 19 | 20 | final String fromEmail = user.getEmail(); // requires valid gmail 21 | // id 22 | final String password = "mypassword"; // correct password for gmail id 23 | final String toEmail = "myemail@yahoo.com"; // can be any email id 24 | 25 | Properties props = new Properties(); 26 | props.put("mail.smtp.host", "smtp.gmail.com"); // SMTP Host 27 | props.put("mail.smtp.port", "587"); // TLS Port 28 | props.put("mail.smtp.auth", "true"); // enable authentication 29 | props.put("mail.smtp.starttls.enable", "true"); // enable STARTTLS 30 | 31 | // create Authenticator object to pass in Session.getInstance argument 32 | Authenticator auth = new Authenticator() { 33 | // override the getPasswordAuthentication method 34 | protected PasswordAuthentication getPasswordAuthentication() { 35 | return new PasswordAuthentication(fromEmail, password); 36 | } 37 | }; 38 | Session session = Session.getInstance(props, auth); 39 | sendEmail(session, toEmail, "TLSEmail Testing Subject", "TLSEmail Testing Body"); 40 | 41 | } 42 | 43 | private void sendEmail(Session session, String toEmail, String subject, String body) { 44 | try { 45 | MimeMessage msg = new MimeMessage(session); 46 | // set message headers 47 | msg.addHeader("Content-type", "text/HTML; charset=UTF-8"); 48 | msg.addHeader("format", "flowed"); 49 | msg.addHeader("Content-Transfer-Encoding", "8bit"); 50 | 51 | msg.setFrom(new InternetAddress("no_reply@gmail.com", "NoReply-JD")); 52 | 53 | msg.setReplyTo(InternetAddress.parse("no_reply@gmail.com", false)); 54 | 55 | msg.setSubject(subject, "UTF-8"); 56 | 57 | msg.setText(body, "UTF-8"); 58 | 59 | msg.setSentDate(new Date()); 60 | 61 | msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toEmail, false)); 62 | System.out.println("Message is ready"); 63 | Transport.send(msg); 64 | 65 | System.out.println("EMail Sent Successfully!!"); 66 | } catch (Exception e) { 67 | e.printStackTrace(); 68 | } 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/App.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.good; 2 | 3 | import java.sql.Connection; 4 | import java.sql.SQLException; 5 | import java.sql.Statement; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class App { 10 | 11 | private final static String CREATE_SCHEMA_SQL = "CREATE TABLE `CUSTOMERS` (`id` INT(11) NULL DEFAULT NULL,`first_name` VARCHAR(50) NULL DEFAULT NULL,`last_name` VARCHAR(50) NULL DEFAULT NULL);"; 12 | private final static String DELETE_SCHEMA_SQL = "DROP TABLE CUSTOMERS"; 13 | private static DatabaseConfig config; 14 | 15 | public static void main(String[] args) throws Exception { 16 | 17 | config = new DatabaseConfig(); 18 | config.setDriverClass("com.mysql.jdbc.Driver"); 19 | config.setUrl("jdbc:mysql://localhost:3306/demo"); 20 | config.setUserName("root"); 21 | config.setPassword("root"); 22 | DataSource dataSource = new MySQLDataSource(); 23 | dataSource.createConnection(config); 24 | CustomerDao customerDao = new CustomerDaoImpl(dataSource); 25 | createSchema(dataSource); 26 | performOperationsUsing(customerDao); 27 | // deleteSchema(dataSource); 28 | 29 | } 30 | 31 | private static void deleteSchema(DataSource dataSource) throws SQLException { 32 | try (Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement()) { 33 | statement.execute(DELETE_SCHEMA_SQL); 34 | } 35 | } 36 | 37 | private static void createSchema(DataSource dataSource) throws SQLException { 38 | try (Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement()) { 39 | statement.execute(CREATE_SCHEMA_SQL); 40 | } 41 | } 42 | 43 | private static void addCustomers(CustomerDao customerDao) throws Exception { 44 | for (Customer customer : generateSampleCustomers()) { 45 | customerDao.add(customer); 46 | } 47 | } 48 | 49 | private static void performOperationsUsing(final CustomerDao customerDao) throws Exception { 50 | addCustomers(customerDao); 51 | final Customer customer = new Customer(4, "Dan", "Danson"); 52 | customerDao.add(customer); 53 | customer.setFirstName("Daniel"); 54 | customer.setLastName("Danielson"); 55 | customerDao.update(customer); 56 | } 57 | 58 | /** 59 | * Generate customers. 60 | * 61 | * @return list of customers. 62 | */ 63 | public static List generateSampleCustomers() { 64 | final Customer customer1 = new Customer(1, "Adam", "Adamson"); 65 | final Customer customer2 = new Customer(2, "Bob", "Bobson"); 66 | final Customer customer3 = new Customer(3, "Carl", "Carlson"); 67 | final List customers = new ArrayList<>(); 68 | customers.add(customer1); 69 | customers.add(customer2); 70 | customers.add(customer3); 71 | return customers; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /oops-concepts/src/main/java/com/ramesh/ood/concepts/aggregation/Aggregation.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.concepts.aggregation; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | // Aggregation = HAS-A Relationship. 6 | // Aggregation is an association represents a part of a whole relationship where a part can exist without a whole. 7 | // It has a weaker relationship. For example, If line-item HAS-A product, then a line item is a whole and product is a part. 8 | // If a line item is deleted, then corresponding product needs not to be deleted. 9 | 10 | public class Aggregation { 11 | public static void main(String[] args) { 12 | // Create Products 13 | Product p1 = new Product(1, "Pen", "This is red pen"); 14 | Product p2 = new Product(2, "Pencil", "This is pencil"); 15 | Product p3 = new Product(3, "ColorBox", "This is color box"); 16 | 17 | // Create lineItem and add quntity of the products 18 | LineItem item1 = new LineItem(1, 2, p1); 19 | LineItem item2 = new LineItem(1, 2, p2); 20 | LineItem item3 = new LineItem(1, 2, p3); 21 | 22 | // Before deleting line item 1 23 | System.out.println(item1.getId()); 24 | System.out.println(item1.getQuantity()); 25 | System.out.println(item1.getP()); 26 | item1 = null; 27 | 28 | // Still product exist and not deleted 29 | System.out.println(p1); 30 | } 31 | } 32 | 33 | /** 34 | * This is Product class 35 | * 36 | */ 37 | class Product { 38 | private int id; 39 | private String name; 40 | private String description; 41 | 42 | public Product(int id, String name, String description) { 43 | super(); 44 | this.id = id; 45 | this.name = name; 46 | this.description = description; 47 | } 48 | public int getId() { 49 | return id; 50 | } 51 | public void setId(int id) { 52 | this.id = id; 53 | } 54 | public String getName() { 55 | return name; 56 | } 57 | public void setName(String name) { 58 | this.name = name; 59 | } 60 | public String getDescription() { 61 | return description; 62 | } 63 | public void setDescription(String description) { 64 | this.description = description; 65 | } 66 | @Override 67 | public String toString() { 68 | return "Product [id=" + id + ", name=" + name + ", description=" + description + "]"; 69 | } 70 | } 71 | 72 | /** 73 | * This is LineItem class, which HAS-A aggregation association with Product class. That means, if you delete LineItem, then associated Product can 74 | * exist. 75 | * 76 | */ 77 | class LineItem { 78 | private int id; 79 | private int quantity; 80 | private Product p; 81 | 82 | public LineItem(int id, int quantity, Product p) { 83 | super(); 84 | this.id = id; 85 | this.quantity = quantity; 86 | this.p = p; 87 | } 88 | public int getId() { 89 | return id; 90 | } 91 | public void setId(int id) { 92 | this.id = id; 93 | } 94 | public int getQuantity() { 95 | return quantity; 96 | } 97 | public void setQuantity(int quantity) { 98 | this.quantity = quantity; 99 | } 100 | public Product getP() { 101 | return p; 102 | } 103 | public void setP(Product p) { 104 | this.p = p; 105 | } 106 | @Override 107 | public String toString() { 108 | return "LineItem [id=" + id + ", quantity=" + quantity + ", p=" + p + "]"; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /oops-concepts/src/main/java/com/ramesh/ood/concepts/abstraction/Abstraction.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.concepts.abstraction; 2 | 3 | //--------------------------------------- 4 | //--- STEP 00 - WHAT IS ABSTRACTION & ENCAPSULATION? 5 | //--------------------------------------- 6 | 7 | ///** 8 | // * Abstraction = Looking only at the information that is relevant at the time. 9 | // * 10 | // * Abstraction is the process or result of generalization by reducing the information content of a concept or an observable phenomenon, 11 | // * typically in order to retain only information which is relevant for a particular purpose. It is starting point of design. 12 | // * Functional abstraction - means that a function can be used without taking into account how the function is implemented. 13 | // * Data Abstraction - means that data can be used without taking into account how the data are stored. 14 | // */ 15 | 16 | ///** 17 | // * Encapsulation = Data hiding mechanism. 18 | // * 19 | // * The process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from 20 | // * outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily 21 | // * accessed by other code defined outside the wrapper. 22 | // * For example - if a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. 23 | // */ 24 | 25 | //--------------------------------------- 26 | //--- STEP 01 - UNDERSTAND ENCAPSULATION BY EXAMPLE 27 | //--------------------------------------- 28 | 29 | /** 30 | * 31 | * Encapsulation goals of Person class 32 | * 33 | * (1) The id and name parameters should not be accessible directly outside Person class - achieved by private declaration 34 | * 35 | * (2) The id value can be assigned in Person class only and other class should not be able to change - not included setId() method 36 | * 37 | * 38 | */ 39 | class Person { 40 | 41 | private double id; 42 | private String name; 43 | 44 | public Person() { 45 | // Only Person class can access and assign 46 | id = Math.random(); 47 | sayHello(); 48 | } 49 | 50 | // This method is protected for giving access within Person class only 51 | private void sayHello() { 52 | System.out.println("Hello - " + getId()); 53 | } 54 | 55 | public double getId() { 56 | return id; 57 | } 58 | 59 | public String getName() { 60 | return name; 61 | } 62 | public void setName(String name) { 63 | this.name = name; 64 | } 65 | } 66 | 67 | /** 68 | * Test class for Person 69 | * 70 | * @author tirthalp 71 | * 72 | */ 73 | public class Abstraction { 74 | 75 | public static void main(String[] args) { 76 | 77 | Person p1 = new Person(); 78 | p1.setName("Tirthal"); 79 | /* 80 | * Note: As id and name are encapsulated in Person class, those cannot be accessed directly here. Also there is no way to assign id in this 81 | * class. Try to uncomment below code and you would find compile time error. 82 | */ 83 | // p1.id = "123"; 84 | // p1.name = "this will give compile time error"; 85 | // p1.sayHello(); // You can't access this method, as it is private to Person 86 | 87 | System.out.println("Person 1 - " + p1.getId() + " : " + p1.getName()); 88 | } 89 | } -------------------------------------------------------------------------------- /oops-concepts/src/main/java/com/ramesh/ood/concepts/encapsulation/Encapsulation.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.concepts.encapsulation; 2 | 3 | //--------------------------------------- 4 | //--- STEP 00 - WHAT IS ABSTRACTION & ENCAPSULATION? 5 | //--------------------------------------- 6 | 7 | ///** 8 | // * Abstraction = Looking only at the information that is relevant at the time. 9 | // * 10 | // * Abstraction is the process or result of generalization by reducing the information content of a concept or an observable phenomenon, 11 | // * typically in order to retain only information which is relevant for a particular purpose. It is starting point of design. 12 | // * Functional abstraction - means that a function can be used without taking into account how the function is implemented. 13 | // * Data Abstraction - means that data can be used without taking into account how the data are stored. 14 | // */ 15 | 16 | ///** 17 | // * Encapsulation = Data hiding mechanism. 18 | // * 19 | // * The process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from 20 | // * outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily 21 | // * accessed by other code defined outside the wrapper. 22 | // * For example - if a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. 23 | // */ 24 | 25 | //--------------------------------------- 26 | //--- STEP 01 - UNDERSTAND ENCAPSULATION BY EXAMPLE 27 | //--------------------------------------- 28 | 29 | /** 30 | * 31 | * Encapsulation goals of Person class 32 | * 33 | * (1) The id and name parameters should not be accessible directly outside Person class - achieved by private declaration 34 | * 35 | * (2) The id value can be assigned in Person class only and other class should not be able to change - not included setId() method 36 | * 37 | * 38 | */ 39 | class Person { 40 | 41 | private double id; 42 | private String name; 43 | 44 | public Person() { 45 | // Only Person class can access and assign 46 | id = Math.random(); 47 | sayHello(); 48 | } 49 | 50 | // This method is protected for giving access within Person class only 51 | private void sayHello() { 52 | System.out.println("Hello - " + getId()); 53 | } 54 | 55 | public double getId() { 56 | return id; 57 | } 58 | 59 | public String getName() { 60 | return name; 61 | } 62 | public void setName(String name) { 63 | this.name = name; 64 | } 65 | } 66 | 67 | /** 68 | * Test class for Person 69 | * 70 | * @author tirthalp 71 | * 72 | */ 73 | public class Encapsulation { 74 | 75 | public static void main(String[] args) { 76 | 77 | Person p1 = new Person(); 78 | p1.setName("Tirthal"); 79 | /* 80 | * Note: As id and name are encapsulated in Person class, those cannot be accessed directly here. Also there is no way to assign id in this 81 | * class. Try to uncomment below code and you would find compile time error. 82 | */ 83 | // p1.id = "123"; 84 | // p1.name = "this will give compile time error"; 85 | // p1.sayHello(); // You can't access this method, as it is private to Person 86 | 87 | System.out.println("Person 1 - " + p1.getId() + " : " + p1.getName()); 88 | } 89 | } -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/bad/singleresponsibility_principles_bad.ucls: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/CustomerDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.good; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | /** 8 | * 9 | * CustomerDaoImpl implements inversion of control. 10 | * It depends on abstraction(DataSource interface) that can be injected 11 | * through its constructor. 12 | * 13 | * If we want to support Oracle database in future 14 | * then client needs to pass datasource implementation as per his/her requirement. 15 | * 16 | */ 17 | public class CustomerDaoImpl implements CustomerDao { 18 | 19 | 20 | private DataSource dataSource; 21 | 22 | //It depends on abstraction(DataSource interface) that can be injected through its constructor 23 | public CustomerDaoImpl(DataSource dataSource) { 24 | this.dataSource = dataSource; 25 | } 26 | 27 | private Connection getConnection() throws SQLException { 28 | return this.dataSource.getConnection(); 29 | } 30 | 31 | private Customer createCustomer(ResultSet resultSet) throws SQLException { 32 | return new Customer(resultSet.getInt("ID"), resultSet.getString("first_name"), resultSet.getString("last_name")); 33 | } 34 | 35 | @Override 36 | public Customer getById(int id) throws Exception { 37 | try { 38 | Connection connection = getConnection(); 39 | PreparedStatement statement = connection.prepareStatement("SELECT * FROM CUSTOMERS WHERE ID = ?"); 40 | statement.setInt(1, id); 41 | ResultSet resultSet = statement.executeQuery(); 42 | if (resultSet.next()) { 43 | return createCustomer(resultSet); 44 | } else { 45 | return null; 46 | } 47 | } catch (SQLException ex) { 48 | throw new Exception(ex.getMessage(), ex); 49 | } 50 | } 51 | 52 | /** 53 | * {@inheritDoc} 54 | */ 55 | @Override 56 | public boolean add(Customer customer) throws Exception { 57 | 58 | try { 59 | Connection connection = getConnection(); 60 | PreparedStatement statement = connection.prepareStatement("INSERT INTO CUSTOMERS VALUES (?,?,?)"); 61 | statement.setInt(1, customer.getId()); 62 | statement.setString(2, customer.getFirstName()); 63 | statement.setString(3, customer.getLastName()); 64 | statement.execute(); 65 | return true; 66 | } catch (SQLException ex) { 67 | throw new Exception(ex.getMessage(), ex); 68 | } 69 | } 70 | 71 | /** 72 | * {@inheritDoc} 73 | */ 74 | @Override 75 | public boolean update(Customer customer) throws Exception { 76 | try { 77 | Connection connection = getConnection(); 78 | PreparedStatement statement = connection 79 | .prepareStatement("UPDATE CUSTOMERS SET first_name = ?, last_name = ? WHERE ID = ?"); 80 | statement.setString(1, customer.getFirstName()); 81 | statement.setString(2, customer.getLastName()); 82 | statement.setInt(3, customer.getId()); 83 | return statement.executeUpdate() > 0; 84 | } catch (SQLException ex) { 85 | throw new Exception(ex.getMessage(), ex); 86 | } 87 | } 88 | 89 | /** 90 | * {@inheritDoc} 91 | */ 92 | @Override 93 | public boolean delete(Customer customer) throws Exception { 94 | try { 95 | Connection connection = getConnection(); 96 | PreparedStatement statement = connection.prepareStatement("DELETE FROM CUSTOMERS WHERE ID = ?"); 97 | statement.setInt(1, customer.getId()); 98 | return statement.executeUpdate() > 0; 99 | } catch (SQLException ex) { 100 | throw new Exception(ex.getMessage(), ex); 101 | } 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/bad/VoiletCustomerDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.principles.dependencyinversion.bad; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | 8 | /** 9 | * 10 | * VoiletCustomerDaoImpl class violet the dependency injection principle and 11 | * have hard dependency with MySQLDataSource instance . It depends on 12 | * MySQLDataSource that has created using new keyword. 13 | * 14 | * If customerDaoImpl class wants to support Oracle database 15 | * then we need to change this for Oracle database configuration. 16 | * 17 | */ 18 | public class VoiletCustomerDaoImpl implements CustomerDao { 19 | 20 | //Hard dependency with MySQLDataSource instance 21 | private DataSource dataSource = new MySQLDataSource(); 22 | 23 | private Connection getConnection() throws SQLException { 24 | return this.dataSource.getConnection(); 25 | } 26 | 27 | private DataSource getDataSource() throws SQLException { 28 | return this.dataSource; 29 | } 30 | 31 | private Customer createCustomer(ResultSet resultSet) throws SQLException { 32 | return new Customer(resultSet.getInt("ID"), resultSet.getString("first_name"), 33 | resultSet.getString("last_name")); 34 | } 35 | 36 | @Override 37 | public Customer getById(int id) throws Exception { 38 | try { 39 | Connection connection = getConnection(); 40 | PreparedStatement statement = connection.prepareStatement("SELECT * FROM CUSTOMERS WHERE ID = ?"); 41 | statement.setInt(1, id); 42 | ResultSet resultSet = statement.executeQuery(); 43 | if (resultSet.next()) { 44 | return createCustomer(resultSet); 45 | } else { 46 | return null; 47 | } 48 | } catch (SQLException ex) { 49 | throw new Exception(ex.getMessage(), ex); 50 | } 51 | } 52 | 53 | /** 54 | * {@inheritDoc} 55 | */ 56 | @Override 57 | public boolean add(Customer customer) throws Exception { 58 | 59 | try { 60 | Connection connection = getConnection(); 61 | PreparedStatement statement = connection.prepareStatement("INSERT INTO CUSTOMERS VALUES (?,?,?)"); 62 | statement.setInt(1, customer.getId()); 63 | statement.setString(2, customer.getFirstName()); 64 | statement.setString(3, customer.getLastName()); 65 | statement.execute(); 66 | return true; 67 | } catch (SQLException ex) { 68 | throw new Exception(ex.getMessage(), ex); 69 | } 70 | } 71 | 72 | /** 73 | * {@inheritDoc} 74 | */ 75 | @Override 76 | public boolean update(Customer customer) throws Exception { 77 | try { 78 | Connection connection = getConnection(); 79 | PreparedStatement statement = connection 80 | .prepareStatement("UPDATE CUSTOMERS SET first_name = ?, last_name = ? WHERE ID = ?"); 81 | statement.setString(1, customer.getFirstName()); 82 | statement.setString(2, customer.getLastName()); 83 | statement.setInt(3, customer.getId()); 84 | return statement.executeUpdate() > 0; 85 | } catch (SQLException ex) { 86 | throw new Exception(ex.getMessage(), ex); 87 | } 88 | } 89 | 90 | /** 91 | * {@inheritDoc} 92 | */ 93 | @Override 94 | public boolean delete(Customer customer) throws Exception { 95 | try { 96 | Connection connection = getConnection(); 97 | PreparedStatement statement = connection.prepareStatement("DELETE FROM CUSTOMERS WHERE ID = ?"); 98 | statement.setInt(1, customer.getId()); 99 | return statement.executeUpdate() > 0; 100 | } catch (SQLException ex) { 101 | throw new Exception(ex.getMessage(), ex); 102 | } 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/bad/interfacesegregation_principle_bad.ucls: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/openclosed/good/openclosed_principle_good.ucls: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/bad/liskovssubstitution_principle_bad.ucls: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/interfacesegregation/good/interfacesegregation_principle_good.ucls: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 52 | 53 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /oops-concepts/src/main/java/com/ramesh/ood/concepts/composition/Composition.java: -------------------------------------------------------------------------------- 1 | package com.ramesh.ood.concepts.composition; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | //--------------------------------------- 7 | //--- STEP 00 - WHAT IS AGGREGATION & COMPOSITION? 8 | //--------------------------------------- 9 | 10 | ///** 11 | // * Aggregation = HAS-A Relationship. 12 | // * 13 | // * Aggregation is an association represents a part of a whole relationship where a part can exist without a whole. 14 | // * It has a weaker relationship. For example, If line-item HAS-A product, then a line item is a whole and product is a part. 15 | // * If a line item is deleted, then corresponding product needs not to be deleted. 16 | // */ 17 | 18 | ///** 19 | // * Composition = HAS-A relationship, but restricted form of Aggregation 20 | // * 21 | // * Composition is an association represents a part of a whole relationship where a part cannot exist without a whole. If a whole is deleted then 22 | // * all parts are deleted. It has a stronger relationship. For example, if order HAS-A line-items, then an order is a whole and line items are parts. 23 | // * If an order is deleted then all corresponding line items for that order should be deleted. 24 | // */ 25 | 26 | /** 27 | * This is test class for aggregation and composition example 28 | * 29 | */ 30 | public class Composition { 31 | public static void main(String[] args) { 32 | // Create Products 33 | Product p1 = new Product(1, "Pen", "This is red pen"); 34 | Product p2 = new Product(2, "Pencil", "This is pencil"); 35 | Product p3 = new Product(3, "ColorBox", "This is color box"); 36 | 37 | // Create Order and Add Line Items 38 | Order o = new Order(1, "ORD#1"); 39 | o.addItem(1, 2, p1); // Ordered of 2 quantity for p1 product 40 | o.addItem(2, 1, p2); // Ordered of 1 quantity for p2 product 41 | o.addItem(3, 5, p3); // Ordered of 5 quantity for p3 product 42 | // Print Order detail before deleting 43 | System.out.println("Order ---"); 44 | System.out.println(o); 45 | // Deleting order would also delete associated LineItems ------- Represents Composition relationship between Order and LineItem 46 | o = null; 47 | // Line items are deleted, but associated products can still exist -------- Represents Aggregation relationship between LineItem and Product 48 | System.out.println("Products ---"); 49 | System.out.println(p1); 50 | System.out.println(p2); 51 | System.out.println(p3); 52 | } 53 | } 54 | 55 | /** 56 | * This is Product class 57 | * 58 | * @author tirthalp 59 | * 60 | */ 61 | class Product { 62 | private int id; 63 | private String name; 64 | private String description; 65 | 66 | public Product(int id, String name, String description) { 67 | super(); 68 | this.id = id; 69 | this.name = name; 70 | this.description = description; 71 | } 72 | public int getId() { 73 | return id; 74 | } 75 | public void setId(int id) { 76 | this.id = id; 77 | } 78 | public String getName() { 79 | return name; 80 | } 81 | public void setName(String name) { 82 | this.name = name; 83 | } 84 | public String getDescription() { 85 | return description; 86 | } 87 | public void setDescription(String description) { 88 | this.description = description; 89 | } 90 | @Override 91 | public String toString() { 92 | return "Product [id=" + id + ", name=" + name + ", description=" + description + "]"; 93 | } 94 | } 95 | 96 | /** 97 | * This is LineItem class, which HAS-A aggregation association with Product class. That means, if you delete LineItem, then associated Product can 98 | * exist. 99 | * 100 | * @author tirthalp 101 | * 102 | */ 103 | class LineItem { 104 | private int id; 105 | private int quantity; 106 | private Product p; 107 | 108 | public LineItem(int id, int quantity, Product p) { 109 | super(); 110 | this.id = id; 111 | this.quantity = quantity; 112 | this.p = p; 113 | } 114 | public int getId() { 115 | return id; 116 | } 117 | public void setId(int id) { 118 | this.id = id; 119 | } 120 | public int getQuantity() { 121 | return quantity; 122 | } 123 | public void setQuantity(int quantity) { 124 | this.quantity = quantity; 125 | } 126 | public Product getP() { 127 | return p; 128 | } 129 | public void setP(Product p) { 130 | this.p = p; 131 | } 132 | @Override 133 | public String toString() { 134 | return "LineItem [id=" + id + ", quantity=" + quantity + ", p=" + p + "]"; 135 | } 136 | } 137 | 138 | /** 139 | * This is Order class, which HAS-A composition association with LineItem class. That means if you delete Order, then associated all LineItem must be 140 | * deleted. 141 | * 142 | * @author tirthalp 143 | * 144 | */ 145 | class Order { 146 | private int id; 147 | private String name; 148 | private List lineItems; 149 | 150 | public Order(int id, String name) { 151 | super(); 152 | this.id = id; 153 | this.name = name; 154 | this.lineItems = new ArrayList(); 155 | } 156 | public int getId() { 157 | return id; 158 | } 159 | public void setId(int id) { 160 | this.id = id; 161 | } 162 | public String getName() { 163 | return name; 164 | } 165 | public void setName(String name) { 166 | this.name = name; 167 | } 168 | 169 | @Override 170 | public String toString() { 171 | return "Order [id=" + id + ", name=" + name + ", lineItems=" + lineItems + "]"; 172 | } 173 | 174 | // Add line item to order 175 | public void addItem(int id, int quantity, Product p) { 176 | this.lineItems.add(new LineItem(id, quantity, p)); 177 | } 178 | 179 | // Remove line item from order for given item id 180 | public void removeItemById(int itemId) { 181 | // TODO - Not implemented yet 182 | } 183 | } -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/liskovssubstitution/good/liskovssubstitution_principle_good.ucls: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 52 | 53 | 55 | 56 | 57 | 58 | 59 | 63 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/singleresponsibility/good/singleresponsibility_principles_good.ucls: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 40 | 41 | 43 | 44 | 45 | 46 | 47 | 51 | 52 | 54 | 55 | 56 | 57 | 58 | 62 | 63 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/bad/dependencyinversion_principles_bad.ucls: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 52 | 53 | 55 | 56 | 57 | 58 | 59 | 63 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /oops-principles/src/main/java/com/ramesh/ood/principles/dependencyinversion/good/dependencyinversion_principles_good.ucls: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 52 | 53 | 55 | 56 | 57 | 58 | 59 | 63 | 64 | 66 | 67 | 68 | 69 | 70 | 74 | 75 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | Posts about Oops Principles, Oops concepts in order to design strong object-oriented design for J2EE Web Applications.
5 | All Oops concepts are explained with real-world examples, lots of source code with an explanation, applicability, class diagrams etc.
6 |

7 | Oops Concepts

8 |
9 |
10 | 42 | 43 | 44 |
45 |
46 | Source code is available on GitHub : Object Oriented Design Guide
47 | 48 |
49 | 64 |
65 | --------------------------------------------------------------------------------