Did you like how we did? Rate your experience!

4.5

satisfied

46 votes

What are some patterns for designing very large programs efficiently?

I'd recommend looking at the problem in two independent ways: what are the patterns / techniques for designing very large programs (independent of the language); the specific challenges of the platform / language of your choice (C in this case). In the field that i'm familiar with (network elements) the typical challenges are:- Define good abstractions. Is it possible to narrow down the problem to interactions between a small set of base object types ? An example: UI libraries are typically built based on 2 concepts: views and events. Views contain child views to which they distribute events. - Define APIs that separate the interface from implementation. - Define a mechanism for communication between modules / features, etc. i.e. Any software project will turn into spaghetti if every class/module is explicitly invoking the APIs of all the other modules that it triggers. Use a mechanism to control this interaction. You can call it the "observer pattern", a SOA design, a service bus, etc. Regarding C: - Use an accounting mechanism for memory allocations. - Develop a pattern to deal with long lived objects (e.g. refcounts) and follow it consistently. - Whenever OO design is a useful pattern you can easily map it to C using a field that identifies the 'class' plus function vectors. - Define a strategy for concurrency. Unless you problem is very simple try to think beyond the typical answer of "sprinkling mutexes" throughout the code. Personally i find that concepts such as Intel Concurrent Collections to be a useful starting point: think of you program as a graph that consumes inputs and produces results.

100%
Loading, please wait...