Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Why is it called 4 pillars of OOPs when we have association too( aggregation/composition )?

 
Ranch Foreman
Posts: 1809
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is generally said there are 4 pillars of composition : inheritance ,polymorphism ,abstraction and encapsulation.

Why is it called 4 pillars of OOPs when we have association too( aggregation/composition )?

Thanks
 
Saloon Keeper
Posts: 12431
269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Egh, this seems like one of those things that someone once wrote and then was endlessly parroted as the World Wide Web tends to do. Do you have any authoritative source that says that these 4 particular features are the pillars of OO? I could mention some other things that are probably at least as important to an OO language.

Anyway, the reason association ISN'T mentioned is twofold. First, it's not really unique to OOP. Heck, you can do association in assembly language simply by referring to a block of memory by storing a memory address in another block of memory. Secondly, aggregation/composition are implementation details that fall under encapsulation.
 
Monica Shiralkar
Ranch Foreman
Posts: 1809
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
Marshal
Posts: 70689
288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you ever work out why you should avoid static variables, as you asked in a different thread?
 
Monica Shiralkar
Ranch Foreman
Posts: 1809
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[quote]Did you ever work out why you should avoid[tt] static [/tt]variables, as you asked in a different thread?[/quote]

My understanding is that if I have to do for example some processing or some computation which does not manipulate class variables  ,then one should make it static.But if I do something that manipulates the class variables then I should instead use instance methods .
 
Campbell Ritchie
Marshal
Posts: 70689
288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read what it said in the other thread about what class variables are?
 
Monica Shiralkar
Ranch Foreman
Posts: 1809
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Did you read what it said in the other thread about what class variables are?



Thanks .Yes, for class variables (known as static variables ) there will be 1 copy of them irrespective of the number of objects created .
 
reply
    Bookmark Topic Watch Topic
  • New Topic