1. 结构化编程:
顾名思义,结构化编程是一种被认为是 OOP 的前身的技术,通常由结构良好且分离的模块组成。在这种编程中,用户可以创建自己的用户定义函数,并且这种方法试图解决与无条件传输相关的问题,以允许程序员遵循程序逻辑。它还需要在设计和逻辑结构阶段更多的纪律。
示例: Pascal、ALGOL、C、Modula-2 等。
2.面向对象编程:
顾名思义,面向对象编程是一种不同的编程方法,它将数据和在其上执行的函数结合在一起。基本支持封装、抽象、继承、多态等,还包含数据隐藏功能,更加安全。该模型基于现实生活中的实体,关注由谁来完成任务,而不是关注做什么。
示例: Java、C#、C++ 等。
结构化编程和面向对象编程的区别:
Structured Programming |
Object-Oriented Programming |
It is a subset of procedural programming. | It relies on concept of objects that contain data and code. |
Programs are divided into small programs or functions. | Programs are divided into objects or entities. |
It is all about facilitating creation of programs with readable code and reusable components. | It is all about creating objects that usually contain both functions and data. |
Its main aim is to improve and increase quality, clarity, and development time of computer program. | Its main aim is to improve and increase both quality and productivity of system analysis and design. |
It simply focuses on functions and processes that usually work on data. | It simply focuses on representing both structure and behavior of information system into tiny or small modules that generally combines data and process both. |
It is a method of organizing, managing and coding programs that can give or provide much easier modification and understanding. | It is a method in which set of objects can vary dynamically and can execute just by acting and reading to each other. |
In this, methods are written globally and code lines are processed one by one i.e., Run sequentially. | In this, method works dynamically, make calls as per need of code for certain time. |
It generally follows “Top-Down Approach”. | It generally follows “Bottom-Up Approach”. |
It provides less flexibility and abstraction as compared to object-oriented programming. | It provides more flexibility and abstraction as compared to structured programming. |
It is more difficult to modify structured program and reuse code as compared to object-oriented programs. | It is less difficult to modify object-oriented programs and reuse code as compared to structured programs. |
It gives more importance of code. | It gives more importance to data. |