It seems there is a lot of discussion on the web about the differences between these two paradigms, and how OOP is somewhat better than structured programming.

But aren't they complementary? From my point of view one could organize his application following OOP principles and implement its logic using structured programming, couldn't he?

有帮助吗?

解决方案

You can argue that OOP builds upon structured programming in general - so yes they are complementary in that sense.

Remember that programming paradigms are mostly about what you don't do:

  • Structured programming removes unconstrained branching and jumping (so that code executes in well-defined structured blocks such as while loops)
  • OOP removes polymorphism via function pointers (instead relying on object methods and virtual dispatch to achieve polymorphism)

You could theoretically conceive of a language that encourages unconstrained branching and jumping but uses objects and OOP-style method dispatch. It would then be OOP but not structured... however it would be a very strange language. I'm not aware of anything like it.

许可以下: CC-BY-SA归因
scroll top