Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Other than inheritance , in real time web development do other OO features have any major role?

Tags:

java

oop

php

In web development we use java .net or php5 . All are OO. and have all the OO features.

But in real time websites do these OO features play any major role other than inheritance.?

Can anybody list some with real time examples.

In application development there may be a vast use of OO. But in case of websites, does OO playing a major role? How?

like image 753
zod Avatar asked Apr 29 '11 17:04

zod


2 Answers

Back in 1995 the book Design Patterns managed to produce this phenomenal insight on page 20:

Favor object composition over class inheritance

Since then, proper object-orientation has been about that instead of inheritance. Particularly, the SOLID principles describe a set of principles for object-orientation that are applicable for any code base where maintainability is important. Polymorphism is important, but inheritance is irrelevant.

That applies to web applications as well as any other type of application.

like image 196
Mark Seemann Avatar answered Oct 23 '22 13:10

Mark Seemann


I make heavy use of encapsulation and polymorphism. Specifically I use the Strategy Pattern (among others) pretty heavily to compartmentalize a great deal of my functionality. When combined with dependency injection, it makes it really easy for me to separate functionality of say, my persistence layer, from my business logic or presentation layer.

For instance, it's trivial to swap out a hibernate implementation with a JDBC implementation, etc. Actually, recently, I just switched from an e-mail service that operates synchronously with the web request to one that uses a message queue to asynchronously send mail. All I had to do once I'd implemented the new layer was change which class was injected into my beans that use it.

Edit: To address your comment, @zod, I don't use it so with with regards to the pages that are executed although that does happen from time to time (for instance, I have different classes for HTML email and plain text email depending on what the user has requested) but I primarily make use of the OO principals in the configuration of the application. Does that make sense?

like image 20
Chris Thompson Avatar answered Oct 23 '22 14:10

Chris Thompson