Questions tagged [oop]

Object-oriented programming is a programming paradigm using "objects": an encapsulation consisting of data fields and methods together with their interactions.

OOP

Object-oriented programming (OOP) is a programming paradigm using the concept of objects. These encapsulates data which is organized in the form of fields (often known as attributes) and code, in the form of procedures (often known as methods). Methods can access and often modify attributes of the object with which they are associated. In OOP, computer programs are designed based on having objects interacting among each other.

OOP includes features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance. Many modern programming languages now support OOP.

FAQs

  1. Interface vs Base class
  2. Prefer composition over inheritance?
  3. Polymorphism vs Overriding vs Overloading
  4. What is a class in PHP?
  5. What's the point of OOP?
  6. Inheritance vs. Aggregation
  7. Object-orientation in C
  8. What are the differences between struct and class in C++?
  9. Interface vs Abstract Class (general OO)
  10. What's the difference between a method and a function?
  11. What is the difference between an interface and abstract class?
  12. What is the difference between an abstract function and a virtual function?
  13. What is the difference between public, private, and protected?
  14. Functional programming vs Object Oriented programming
  15. Difference between abstraction and encapsulation?
  16. How do you design object oriented projects?
  17. Difference Between Cohesion and Coupling
  18. prototype based vs. class based inheritance
  19. Aspect Oriented Programming vs. Object-Oriented Programming
  20. What is polymorphism, what is it for, and how is it used?
61861 questions
7262
votes
25 answers

What are metaclasses in Python?

What are metaclasses? What are they used for?
Bite code
  • 578,959
  • 113
  • 301
  • 329
4574
votes
36 answers

@staticmethod vs @classmethod in Python

What is the difference between a method decorated with @staticmethod and one decorated with @classmethod?
Daryl Spitzer
  • 143,156
  • 76
  • 154
  • 173
3182
votes
7 answers

Understanding Python super() with __init__() methods

Why is super() used? Is there a difference between using Base.__init__ and super().__init__? class Base(object): def __init__(self): print "Base created" class ChildA(Base): def __init__(self): Base.__init__(self) …
Mizipzor
  • 51,151
  • 22
  • 97
  • 138
2296
votes
39 answers

What is Inversion of Control?

Inversion of Control (IoC) can be quite confusing when it is first encountered. What is it? Which problem does it solve? When is it appropriate to use and when not?
2211
votes
24 answers

When should I use 'self' over '$this'?

In PHP 5, what is the difference between using self and $this? When is each appropriate?
Casey Watson
  • 51,574
  • 10
  • 32
  • 30
2137
votes
42 answers

What's the difference between a method and a function?

Can someone provide a simple explanation of methods vs. functions in OOP context?
willc2
  • 38,991
  • 25
  • 88
  • 99
1993
votes
38 answers

What is the difference between an interface and abstract class?

What exactly is the difference between an interface and an abstract class?
Sarfraz
  • 377,238
  • 77
  • 533
  • 578
1962
votes
35 answers

Prefer composition over inheritance?

Why prefer composition instead of inheritance? What trade-offs are there for each approach? And the converse question: when should I choose inheritance instead of composition?
readonly
  • 343,444
  • 107
  • 203
  • 205
1886
votes
12 answers

Meaning of @classmethod and @staticmethod for beginner

What do @classmethod and @staticmethod mean in Python, and how are they different? When should I use them, why should I use them, and how should I use them? As far as I understand, @classmethod tells a class that it's a method which should be…
user1632861
1844
votes
37 answers

Why use getters and setters/accessors?

What's the advantage of using getters and setters - that only get and set - instead of simply using public fields for those variables? If getters and setters are ever doing more than just the simple get/set, I can figure this one out very quickly,…
Dean J
  • 39,360
  • 16
  • 67
  • 93
1793
votes
18 answers

What is the meaning of single and double underscore before an object name?

What do single and double leading underscores before an object's name represent in Python?
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
1714
votes
27 answers

What is the difference between an abstract method and a virtual method?

What is the difference between an abstract method and a virtual method? In which cases is it recommended to use abstract or virtual methods? Which one is the best approach?
Moran Helman
  • 18,432
  • 4
  • 23
  • 26
1694
votes
28 answers

Why not inherit from List?

When planning out my programs, I often start with a chain of thought like so: A football team is just a list of football players. Therefore, I should represent it with: var football_team = new List(); The ordering of this list…
Superbest
  • 25,318
  • 14
  • 62
  • 134
1656
votes
6 answers

Why do Python classes inherit object?

Why does the following class declaration inherit from object? class MyClass(object): ...
tjvr
  • 17,431
  • 6
  • 25
  • 26
1550
votes
34 answers

Interface vs Abstract Class (general OO)

I have recently had two telephone interviews where I've been asked about the differences between an Interface and an Abstract class. I have explained every aspect of them I could think of, but it seems they are waiting for me to mention something…
Houman
  • 64,245
  • 87
  • 278
  • 460
1
2 3
99 100