I'm currently involved in a scrum-ban (mixture of SCRUM and kanban) team where we have a wide range of developer ability levels. I'm referring to "developer ability level" in the common senses of the term, i.e. time taken to write working and maintainable code combined with communication/teamwork skills combined with general design skills, etc.
Although the sprint backlog is split up into workable tasks, some tasks are more complex and/or critical than others. As is generally done in scrum, these tasks are not specifically assigned to developers and can be picked up by whoever feels up for working on any given task.
This issue that comes up is that if a more complex or critical task is completed by a less-capable developer, the resulting code is almost invariably sub-optimal in terms of correctness, maintainability, and design.
Ideally, only the most complex or critical tasks would be taken up by the more capable developers, while more simple tasks could be covered by the less-capable developers. However, specifically assigning tasks to specific developers goes against what is mandated by scrum. What are some effective techniques to deal with this situation? Or is it just better to not use scrum in this situation?