Skip to content

Code seems desperately un-modular and hard to reuse. #245

@mutantbob

Description

@mutantbob

The AppData class is just an ever-growing pile of related fields. A great many of those fields should be grouped together in independent pluggable/reusable structs.

A great many functions accept an AppData just so they can access the device and queue. Those fields could probably be grouped in a context struct that is not tangled with the buffers.

So many functions write to fields in AppData. E.g. create_command_pool() when they should probably just return the command pool and let App::create() store it in the correct field.

The App::create() function instantiates an incomplete AppData object and then calls multiple methods to mutate it. This is not optimal code style since the data variable spends a great deal of time in an incomplete state. Ideally there should be an AppData::new(...) that accepts the instance, device, etc.; constructs the necessary fields; and returns a valid and complete AppData object.
Basically, any place you pass &mut should be reviewed to see if it can be improved.

Solving this issue will be quite traumatic. The code right now is optimized for brevity and simplicity of the tutorial. "fixing" the code to be more Rust-y would be a major effort (having to redo all of the stages, both code and text narrative).

Metadata

Metadata

Assignees

No one assigned

    Labels

    tutorialAn issue relating to the tutorial

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions