Design for Graphic Rendering in Java with Unspecified Update Reasons (Hierarchical) -
original question
i'm working graphic rendering part of program, , got several severe problems previous design.
so, want ask how design structures of renderers , models. or there specific design pattern handle case?
currently have hierarchical implementations of
- renderers (graphics)
- models (data render, receive updates)
i accepted hierarchy since rendered contents can classified, , should managed separately.
there several limiting conditions:
- rendering done on rendering loop.
- there many types of renderers , models, , design should not aware of them.
- there various reasons update models.
- update reasons should not specified in design itself, since various reasons can added.
- models aware of possible update reasons itself.
- renderers have render passes , render helpers.
- types of render passes dependent classes(groups) of renderers.
- render helpers should provided, , each renderer should able use different version of it.
edit: code explain current situation.
renderer:
public interface irenderer<settings, pass, model, helper> { public void initialize(settings settings); public void prerender(settings settings, helper info); public void renderpass(model model, pass pass, helper info); public void postrender(settings settings, helper info); }
model:
public interface imodel<settings, updateinfo> { public void initialize(settings settings); public void update(settings settings, updateinfo update); }
edit2: since update reasons not specified , can contain various information, have problem updating model.
specifically, type of update information varies each update reason, makes hard check types in compile time.
(if helps, update information contain
- changed settings settings change
- updated data user interaction
- spontaneous changes system loop
and on)
how should control update part here? there design pattern solve problem , let code cleaner?
Comments
Post a Comment