I am lumping computer, tablet, and smartphone usage roughly together in this answer, both because it's rare for a child to be using only one of these devices, and because their applications (internet, gaming, social media) significantly overlap.
My general goal is to teach ways to responsibly and productively use technology, enforce limits when they aren't yet self-regulating their activities.
Except for discussion, the categories below may shift over time and depending on the interests and activities of any given child. Hopefully I can establish enough common sense and well-reasoned arguments during middle school years that supervision and enforcing balance are things that they can start doing for themselves. Without conversations, that information isn't going to get conveyed. If I set a time limit for playing games or tie it to doing chores, I explain why. If they aren't allowed to visit a certain category of website or use a certain app, I give an explanation (in many cases, their membership would violate TOS) or context.
Supervision. This is a rather broad concept, and is interpreted differently depending on the parent, the maturity level of the child, and the content they are most frequently accessing.
I don't keylog everything they do, but I do know how to get to my server logs so I have an idea about what websites are being visited, and when. (This is useful when a discussion needs to happen or a boundary needs to be established – if they're up late posting on Facebook, they're not getting enough sleep, and the logs will tattle on them, and I'll know it's time to have a chat about how important sleep is and if necessary we'll start impounding the tablet at 8pm or whatever.) More usefully, the laptops and tablets are used in a communal area of the house – typically kitchen table or family room. I have a very good idea of what they're doing simply by glancing over every ten minutes.
The goal here is not to control every interaction or activity, but rather to know what they're looking at. Is most of the time spent reading Wikipedia and learning something, or playing Flash games? What kind of games (strategy, action, puzzle, etc.)? Also, I can gauge whether this is really "value add" time (i.e. there's educational value here), or "vegetation" time. Relaxing with a computer game is not bad per se, but it doesn't need to happen for hours at a stretch. Similarly, if they're reading articles, that's more valuable than reading the latest Top Ten List of Shocking Foods You Didn't Know About.
By understanding their interest and usage pattern, I'm getting to know my kid – what they're good at, what they're passionate about, etc. It gives me possible topics of conversation ("Hey, were you looking at spaceship videos yesterday? What are your thoughts about this mission to Mars?").
Talk to their kids about electronic activities.
I show them things I'm doing. Occasionally this is a sort of cheating way to pay attention to them while I'm actually working on my own stuff, but it also gives them an idea of what one can do on the computer, why one would be interested in it, and how or where it can be found.
Games aren't purely a waste of time, and can be a great way to relax. Games can also become a giant time sink, investing a lot of time and emotional energy in a wholly virtual space. I share stories about myself getting "too much into" things as a way of pointing out that it can happen. I refer back to those stories when I'm trying to get them to switch to a different activity. ("You've been on Minecraft for hours, remember how Mommy told you about nearly flunking a class because of WoW? Hit save and take a break.")
There's plenty of educational content online, but there's even more useless junk. Even ignoring content that isn't age appropriate, there's a great deal of uninformed or factually inaccurate material presented, and kids generally don't have good filters to know what's "good" educational stuff and what's not. Conversations about what they want to learn about, and where they're learning about it, can help lead to conversations about quality sources and less worthwhile ones.
If they want to research something online, I suggest starting points for research. Google is ok, but often kids search poorly. My child wanted to know about birds in our backyard and why she only saw certain ones. Her search terms ("birds in backyard") led to videos of birds in other people's backyards. I helped her find the Audobon bird guide, and that, she had a lot more fun with – especially enjoying making the computer play a wide variety of bird songs and then trying to imitate them. My feedback and direction were minimal, but it helped her get to a point where she enjoyed and learned a great deal more.
If they feel I've set too tight of a time limit or content limit, they know they can talk to me about it. And I am happy to have a conversation about it, because they get a chance to convince me I'm wrong. That means they need to think about a compelling reason – "I have to get three stars on that Angry Birds level" is unlikely to work, but "Angry Birds has some really interesting game physics and visual design" means they're at least pretending to have some level of interaction beyond simple fun. "Everybody else in my class has their own laptop" is unlikely to work (and blatantly untrue), but describing why it will benefit you is at least a reasonable start.
Social media. Oh, social media…
Talk to kids about how social media works and both its risks and benefits.
It's great to be able to share links and photos and anecdotes with your friends, particularly those you don't see at school every day. It's also a potential minefield for online bullying, and even well-intentioned interaction can go wrong if misinterpreted.
In a real-life conversation, it's easier to judge whether a comment is a joke or an insult – and it's also possible for a friend to notice their intended joke was misinterpreted and apologize for the confusion. The lack of nonverbal cues (see section above) can make social media more stressful than face-to-face communication. Tweens/teens typically feel awkward and self-conscious anyway, and the streamlined simplicity of social media "conversations" gives no context or nonverbal cues, and that can push them even further into self-doubt.
Rachel Simmons, "The Secret Language of Girls on Instagram." Time.
Not only is it important to be aware of the impact that other kids can have on your own children, it's important to also help them think about how they're impacting others. It can be really easy to type something nasty online, easier than talking face-to-face to a person. But it's just as hurtful (if not more so, see prev paragraph). If you're against mean behavior in person, make it clear that the same rules apply on the internet.
It's also very easy to see everybody talking about fun, parties, and wonderful positive things, and feel like you're the only person in the world who's angsty, having friend problems, struggling with schoolwork, tired and hormonal, madly in love with somebody who doesn't love you back… and that isolation hurts, and drives you to further bury the negative feelings so as to not depress all the happy people. That isn't healthy.
Maia Szalavitz, "Misery Has More Company Than You Think, Especially on Facebook." Time.
Finally, controlling access to one's personal information is important, particularly for kids who are more likely to have to deal with cyberbullying or online predators. Ensure they understand whether an app or platform is posting their location (or whether they are), and the risk of having that information publicized. Go through privacy settings with them, explaining the ramifications of each setting. For example, you could say "This setting means that anyone in the world can find out where I am when I post a status update. I have this off on my personal account. I'd be more worried about your physical safety if you don't leave this turned off. Do you think this is a good or bad idea?". When they start signing up for things without my help or permission, they'll have some understanding of what all that privacy stuff is about and why they should think about it.
Balance. The electronic device shouldn't be the primary activity.
Kids need to learn how to interact with people in the physical world. Even a kid destined to be a hardcore programmer will still have to cope with physical human interaction: employers, landlords, friends, romantic partners, even grocery store cashiers.
One study found that taking tweens away from electronics for less than a week resulted in a significant increase in their ability to understand body language and facial expression. They weren't being specifically taught about body language and facial expressions during those five days, they were just interacting with their peers in person instead of on a phone – and that led to a measurable increase in their capacity for understanding interpersonal interaction.
the results suggest that digital screen time, even when used for social interaction, could reduce time spent developing skills in reading nonverbal cues of human emotion.
Uhls et al. "Five days at outdoor education camp without screens improves preteen skills with nonverbal emotion cues." Computers in Human Behavior. doi:10.1016/j.chb.2014.05.036
Encourage interaction with friends independent from social media. If a computer activity is their passion, it can be helpful to look for a club or interest group where like-minded individuals talk about these topics.
This is perhaps the hardest category for a child to self-regulate. If it's an enjoyable activity, why not keep doing it? Especially if it's enjoyable and educational or productive in some way – it is easier to convince one's parents that designing web apps is a healthier time investment than Angry Birds. However, it's still not healthy.
I'd like my kids to grow into well-rounded adults who are able to appreciate a variety of subjects. If their enthusiasm and passion is computer science, that's great: they're following in my footsteps. But I also would like them to know how to feed themselves, relax and be inspired by a walk outside, know how to interact with other people so they can function in society (and for their jobs be able to design products that other people want to use), do their laundry, watch bad sci-fi movies and laugh, have a sensible discussion about current events, and so much more.