UC computer science professor Nan Niu is studying how coders use the Internet to "forage" for information.
Latest Magazine
September 2018
Boldly Bearcat
Finding his voice
Danger in the tap
Virtual defense
Global game changer
Celebrating UC's Bicentennial
Past Issues
Browse our archive of UC Magazine past issues.
A quicker quest for code
Finding the right code costs computer programmers as much as one-third of their time. UC professor Nan Niu is developing tools to help.
By Michael Miller
513-556-6757
Photos by Joseph Fuqua II/UC Creative Services
Dec. 8, 2017
Writing computer code is a collaborative effort that builds continuously on past achievements.
“It’s the beauty of standing on the shoulders of giants,” University of Cincinnati computer scientist Nan Niu said.
But over time, as coders pile new functions atop old ones, a code as elegant as a Shakespearean sonnet can take on a jumbled “spaghetti shape,” said Niu, an assistant professor of computer science at UC’s College of Engineering and Applied Science.
“Change one thing and it could have unintended consequences,” he said. “You fix one computer bug and inadvertently introduce 10 more.”
Studies have found that computer programmers spend as much as one-third of their time navigating the code base to solve a problem or fix a bug.
Niu and graduate student Xiaoyu Jin are studying the way coders hunt for these solutions to help them come up with better search strategies. This could help save time and improve efficiency.
Niu and Jin presented their findings in October at the Institute of Electrical and Electronics Engineers’ Symposium on Visual Languages and Human-Centric Computing.
“Studies show that 90 percent of web users don’t go beyond three pages of search results,” Niu said. “But in software you might go to 190 results. There’s a personal investment factor — hoping there will be something better if you look hard enough.”
Niu said programmers routinely underestimate the amount of time they think it will take them to find the coding solutions they seek on the web, despite how often they conduct these searches. Just like everyone else who uses the internet, coders can fall down a rabbit hole while looking for information, Niu said.
“If code is king, context is god,” Niu said. “You always need to consider the context of the problem and how the solution suits your needs.”
Code is everywhere
Why should anyone care about computer code? The easier it is for programmers to find the precise code they need, the less likely they will end up with spaghetti code that leads to systems catastrophes, Niu said.
The Atlantic summarized the problem in an article headlined, “The Coming Software Apocalypse.” The story chronicled code-related nightmares on the same day in July this year that grounded United Airlines’ fleet, suspended trading on the New York Stock Exchange, crashed the website of the Wall Street Journal and shut down the 911 system in Seattle.
“The simultaneous failure of so many software systems smelled at first of a coordinated cyberattack. Almost more frightening was the realization, later in the day, that it was just a coincidence,” the Atlantic’s James Somers wrote. “There will be more bad days for software. It's important that we get better at making it.”
And computer code is becoming more ubiquitous in everything we do. The average luxury car today has 150 million lines of computer code supporting all of its sensors, performance, cabin comforts and entertainment. Code is everywhere.
“With bits of code all over the internet, it’s hard to find good sources. If there were other tools available, that would be tremendous,” said Michael Wagner, the paper’s co-author, an associate professor at UC and a biomedical informatics researcher at Cincinnati Children’s Hospital Medical Center.
“It’s almost like a crime-scene investigation to string together the answer.”
‒ Nan Niu, UC assistant professor of computer science
The experiment
Niu and Jin invited 20 software developers to participate in an experiment to perform two software tasks. Wagner provided the student test subjects.
“They needed volunteers to do a controlled experiment,” Wagner said. “They approached me when they needed to find a target audience of nontraditional developers — people who aren’t necessarily trained to do code development who use programming languages opportunistically.”
Niu found a skills gap in internet foraging between full-time programmers who are adept at tracking down code and part-time coders such as those he used in the experiment.
Not everyone conducts a web search with the same goal in mind. The researchers identified four different ways people browse the internet: by a site’s ranking or popularity, by examining items in a list in which the time invested corresponds to the knowledge gained, by researching a topic in depth or by looking for a quick answer and moving on.
The researchers wanted to find a way to rank web pages so developers could tell which would be most likely to provide the answers they wanted.
They turned to an idea called Information Foraging Theory. Niu’s research is heavily influenced by the pioneering work of Palo Alto Research Center’s Peter Pirolli, who first compared internet foraging to the effective way predators hunt “patches” of habitat for food.
“If code is king, context is god. You always need to consider the context of the problem and how the solution suits your needs.”
‒ Nan Niu, UC assistant professor of computer science
Niu said predators search for prey within patches rather than jumping quickly from patch to patch. Information Foraging Theory, too, suggests people will have better results by narrowing their search to the right “patch” and hunting within it.
“Once you’re in the patch, you face an optimization problem to predict whether you should stay in the patch or leave for a new patch,” Niu said.
The UC researchers hypothesized that by first considering a web page’s relevancy, organization of content and amount of content, developers could find useful code easier and faster.
The researchers found that by giving the 20 test subjects tools to evaluate both the amount of content per site and how easy or difficult it is to find that content on each site, the programmers needed less time to complete their task. They called this toolkit the “Cost Estimator.”
The 20 test subjects, all of whom considered writing computer software to be an essential part of their job, were asked to solve two relatively complicated coding tasks both on their own and with the help of the researchers’ Cost Estimator, which summarized how much content was on each site they searched and gauged how easy or hard it would be to find useful information within the site.
The results
Niu and Jin recorded programmers’ computer screens to see how they went about solving their coding tasks, which websites they picked and how long they spent on the pages. Niu played one sample video recording that showed a ghostly cursor moving around a computer screen, selecting websites and cutting and pasting pieces of code.
“This ‘predator’ was very careful. He parsed individual lines of code from different sources one at a time,” Niu said of the test subject’s choices.
In coding — as with many other types of internet searches — programmers rarely found a complete answer in one place. Instead, they had to piece together information for their project, Niu said.
“It’s almost like a crime-scene investigation to string together the answer,” Niu said.
Programmers who used the Cost Estimator toolkit cut their task time by an average 9 percent on one task and 21 percent for the other. The findings for the second task were statistically significant. The experiment findings suggested that these kinds of tools might be useful for programmers, Jin said.
“I think my research can provide guidelines to improve the efficiency of codes, mainly by shaping the current search engine,” Jin said. “If a developer can have some options to customize the search results, they can find answers in a better and faster way.”
Niu’s research, including this study, was funded by a five-year $400,000 National Science Foundation Career grant.
Careers in computer science
Industry demand for talented web and software developers is on the rise. At UC's College of Engineering and Applied Science, computer science students learn the skills they need to thrive in a competitive marketplace. Check out the Department of Electrical Engineering and Computer Science or explore other programs on the undergraduate or graduate level.