Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Brajesh KumarRank #678 · 3.5K reputationPosted Mar 1, 2017, 8:51 PM EST
Following two concept is explain everything the use of OOPs.
1. Duplicate code is a Bad.
2. Code will always be changed.
So, above statement proves, OOPs is provides code reusability which reduce the duplication of code because once you have duplicate code, you have make changes everywhere which leads to performance. Code can be changed anytime or requirement of application changed anytime so when you want to make changes in your application, OOPs makes it easier.
Features of OOPs.
There are three main features of OOPS.
1. Abstraction: Learn abstraction here(PHP 5 Abstract classes and Methods)
2. Polymorphism : is a feature that allows one interface to be used for a general class of actions. It’s an operation may exhibit different behavior in different instances.
3. Inheritance : The process by which one class acquires the properties and functionalities of another class. Inheritance provides the idea of reusability of code and each sub class defines only those features that are unique to it.
Advantages of OOP
Object-Oriented Programming has the following advantages:
Approach to Object Oriented Design:
1. Start with the simple object which can be abstracted into individual classes.
2. Identify all the classes in the requirement specification.
3. Identify the commonalities between all or small groups of classes. Do not force fit generalization where it doesn’t make sense.
4. Keep all the data members private or protected
5. Identify all the member variables and methods the class should have
6. Ensure that the class is fully independent of other classes and contains all the necessary attributes and methods.
7. The methods in the class should be abstract.
8. Don't use the procedural code into a class for the methods in the class.
9. Inherit and extend classes from the base classes when require.
10. Define the "Has-A" or "Uses-A" relationships among the classes
Image Source: Google.
Gnanavel SekarRank #333 · 7.5K reputationPosted Mar 1, 2017, 8:52 PM EST
Rafnas T PRank #280 · 8.8K reputationPosted Mar 1, 2017, 8:57 PM EST