1

I am reading a book "Black-Box Testing by Boris Beizer". In this book, there is a sentence as follows,

Object-oriented programming and improved operating systems promise to eliminate many currently common inter-component interaction bugs.

While I understand Object-Oriented design concept (such as in Java Programming language), where everything is related to objects, confined to classes and well-established relation amongst classes. But, I am not able to justify the above statement in relation to Software Testing.

How Object-Oriented design can eliminate bugs? Please help me to understand above statement.

threeA's
  • 19
  • 1
  • 2
    Possible duplicate of [Why is Encapsulation considered a primary principle in OOP?](http://softwareengineering.stackexchange.com/questions/230515/why-is-encapsulation-considered-a-primary-principle-in-oop) – gnat Apr 07 '17 at 12:00
  • see also [How do I prove or disprove “God objects” are wrong?](http://softwareengineering.stackexchange.com/a/178319/31260) – gnat Apr 07 '17 at 12:01
  • @gnat: That's a bit of a stretch. If you're saying that "encapsulation" is the answer, it's not; it's the *question.* If you're saying "your answer is over there," it isn't; very little discussion about bug prevention is taking place over there. – Robert Harvey Apr 07 '17 at 16:52
  • There is a famous article called: "Object Oriented Programming is an expensive disaster which must end." Maybe start there? –  Jun 07 '17 at 14:54

2 Answers2

1

One major source of bugs is the programme's variables getting into an invalid state. This could be:-

  • Where a variable is uninitialized or out of range.
  • Where two closely related variables are out of step with each other (for instance is one is modified, but the other isn't).

In a traditional procedural programme with global variables, it's hard to ensure that all variables are always valid. Eliminating global variables tends to result in state variables being passed from procedure to procedure to procedure, which still doesn't help.

In Object Oriented programmes, the state variables are encapsulated within objects. State can only be modified by the object's own methods, and the object can ensure that related state variables are all updated together.

A set of unit tests can be written ensure that each object's methods always leave that object in a valid state.

Simon B
  • 9,167
  • 4
  • 26
  • 33
0
  • compilers reduce "syntax-errors-at-runtime-bugs",
  • encapsulation can reduce inter-component interaction bugs.
  • There are still many other types of bugs that are more dominant today.

Translate the above statement

Object-oriented programming and improved operating systems 
promise to eliminate many currently common inter-component 
interaction bugs.

to

 Objectorientation reduce the need for global variables which can cause many errors
k3b
  • 7,488
  • 1
  • 18
  • 31
  • 2
    I don't think this really addresses the question; avoiding global variables and globally modifiable state is a general software engineering principle which can be applied to any approach or platform. There's nothing particularly about object orientation which reduces the need for global variables. – Ben Cottrell Apr 08 '17 at 08:48
  • I agree that "avoiding global variables and globally modifiable state is a general software engineering principle". OO has made this easier. – k3b Apr 08 '17 at 09:11