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.

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.

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
  • 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 8 '17 at 8:48
  • I agree that "avoiding global variables and globally modifiable state is a general software engineering principle". OO has made this easier. – k3b Apr 8 '17 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.