John D. Gannon, 51, chairman of the computer science department at the University of Maryland and a well-known researcher in software engineering who helped his department achieve high national rankings, died of a heart attack June 12 at his Silver Spring home. He had a heart ailment.

He joined the computer science staff in 1975 and specialized in the specification, analysis and testing of software systems. Since he took over as chairman of the department four years ago, undergraduate enrollment had nearly doubled, to about 2,000 students, associates said.

Dr. Gannon was among those administrators who helped the computer science department achieve consistently high rankings by professional associations and national organizations such as the National Science Foundation.

Some placed it among the top 10 university departments in the country, his colleagues said. He also helped plan his department's new instructional building, which is to be built next year.

Dr. Gannon was born in Providence, R.I. He was a graduate of Brown University, where he also received a master's degree in computer science. He received a doctorate in that subject from the University of Toronto.

At Maryland, his honors included the Distinguished Scholar-Teacher Award. He was a member of the board of governors of the Computing Research Association and chairman of the Graduate Record Examination Board's computer science committee. He was also a program officer with the National Science Foundation and a fellow of the Association for Computing Machinery.

Survivors include his wife, Nancy Garrison of Silver Spring, and a brother.