When Sonja Khan started college, she'd never thought of studying computer science. But when she heard from friends that the intro class was good, she decided to give it a try - and then ended up majoring in it.
Four years later, she has just graduated with a computer science degree, is pursuing a master's degree and is headed to a summer internship at Facebook.
"I didn't even know anything about the field before; I had never considered it," she said. "I signed up for it pretty much on a whim and really enjoyed it."
Khan's story reads like a dream for universities and technology companies - where only about 15 percent of computer science graduates and technical workers are women. The industry has been under pressure to recruit more. The difficult question, though, is how to encourage more women on paths like Khan's.
Some colleges have made significant strides, including the University of Washington, where Khan is a student. Their methods offer lessons for other colleges and companies hoping to increase the number of women in fields where they remain underrepresented.
Behind the scenes of many of these colleges' efforts is an organisation called the National Center for Women & Information Technology. It provides consultants to college faculties on how to change their programmes to recruit and retain women. Recently, the centre gave the University of Washington its first award, sponsored by Google, for colleges that have succeeded in this effort.
Thirty per cent of University of Washington bachelor's degrees in computer science last year went to women. Ed Lazowska, chairman in computer science and engineering at the university, called that share "not great." Still, it is twice the national average and up from 20 per cent in 2010 and 15 per cent in 2005.
The university has done three big things to diversify its student base, Lazowska said. The first is to get girls interested in computer science early on, by teaching elementary and high school teachers and students about computing through workshops and field trips. Still, like Khan, many students, and particularly girls, are not exposed to the subject before college.
That is why the university gave its introductory courses a makeover a few years ago. The goal was to make computing more accessible and inviting to a broader range of people, Lazowska said. The courses showed students that they can succeed through hard work and do not need esoteric knowledge.
The new program includes small group sessions with faculty members, classes that connect software programming to philosophy or biology and an emphasis on real-world applications. Forty per cent of the teaching assistants are women, and there is a seminar on women in computing.
The University of Washington has also tried to build a sense of community for women studying the topic. It sends students to tech companies or conferences for women in tech to meet others in the field.
For Khan, there were several events that pushed her to continue in the major. A small yet critical one happened early on, she said: After she took the first introductory class, the professor emailed her to encourage her to take the next one.
The seminar on women in computing gave her a chance to discuss some of her insecurities about the field, she said. And as a freshman, she entered a hackathon with friends - despite being worried that she was underqualified to enter - and won second place.
Her university's efforts mirror what other universities have tried to do. Indiana University, which has used data to track efforts to increase women's enrollment, won a second-place award from the National Center for Women & Information Technology.
"It's not just the sink-or-swim mentality, which in my humble opinion has been present in too much of computing education," said Lucy Sanders, co-founder of the centre.
Harvey Mudd increased its share of women studying computer science by doing things like including pictures of women in school brochures and hiring female students as campus tour guides. Carnegie Mellon started a formal mentorship programme for women studying the subject. The focus on recruiting and retaining women might increase their numbers but also singles them out, say some critics of programmes that change curriculums to attract more women or offer classes specifically for women. But Sanders says the American computer science curriculum is in need of a complete overhaul, not just for women.
"I don't particularly think that the existing computer science curriculum has been effective for anybody," she said. "It needs to be situated in a real-world or meaningful context so people understand why they're doing it. That doesn't make it less rigorous - students learn the same things, but in a different way."
© 2015 The New York Times