MVC implemented in pure C

前端 未结 3 1854
我寻月下人不归
我寻月下人不归 2020-12-22 18:03

Does anybody know of any resources that provide a straight forward example of trying to do Model View Controller design pattern in a C context? And in particular an embedded

3条回答
  •  清酒与你
    2020-12-22 18:06

    I'm interested in what suggestions people might have but I think you've hit the nail on the head - It probably doesn't make sense because of the lack of Formal OOP constructs.

    However; it is possible to introduce OOP concepts to ANSI-C; I've had a link to this PDF for a while and whilst I've never really absorbed it (because of no exposure to C in my day to day job) it certainly looks to be fruitful:

    http://www.planetpdf.com/codecuts/pdfs/ooc.pdf

    It's a big task but you could ultimately come up with some kind of template/frame work that would make it very easy to write further MVC style development; but I guess the trade off is - can you afford the time ? Are the limitations of the embedded platforms such that the benefits of the clarity afforded by MVC are outweighed by the lack of performance/memory protection/garbage collection and of course the sheer effort of having to re-invent the wheel ?

    I wish you luck and I'll be very interested to see what you come up with!

    Edit:

    As an after thought, perhaps just having some of the techniques of OOP without going as far as to do a full MVC implementation might help to solve your problems - If you could implement a proper polymorphic hierarchy with Interfaces, you'd have gone a long way to the goal of code reuse.

    This other stackoverflow deals with implementing OOP in Ansi C, it's an interesting read but links to the same pdf: Can you write object-oriented code in C?

提交回复
热议问题