perplexed with code reuse and adopt design pattern in C

Hi all guys,

As an embeded programmer with five year C experience, I did read many great books related with design, coding, test,debug,algorithms, compiler, design, os, pm and others.

I always dream to achieve a refined and reusable design and implementation.

I am very interested with code reuse. I studied "c interfaces and implementations", "refactoring", "gof's design pattern" These days, I go through "head first design pattern" again. but I am still perplexed with code reuse and design reuse.

I assure great works adopted many classic design pattern or design experience. but I found traditional design pattern is face to those OO language(such as C++, java and etc.) It seems very difficult to apply those famous design pattern or experienced princple in C.

Is there any one have the experinece, pratice or suggestion with my puzzle?

In other word, How can we dig out and adopt the classic design experience from experts?

I know code reading and pratice may be a correct way. but it seems grows slowly.

Is there a better way to improve the design ability?

Any comments is appreciated and thankful.

Sailor

Reply to
sailor.gu
Loading thread data ...

I am very little experienced... but... I think code resue is also related to layers of data abstraction.

The more C functions, modules and C objects you have... can distance yourself away from the hardware - the easier it is to reuse code.

The more layers of C functions, modules and C object you have... the more code space and data space required in your micro.

So .... is it economical to use an RTOS and C++ objects for simple embedded products -say a heating controllers in a high volume product. Obviously -not - because you will need mountains of code and data space.... which will price the micro and the product out of business.

If you a making a set of audio players like IPODs then an RTOS and code resuse will be handy.

If you are using the same microcontroller series through out your product range then you can reuse the peripheral C functions over and over.

JG

Reply to
Joe G (Home)

Thanks for your comments. I am involved to develop telecom communication equipment and network products. such as wireless ap, router, gateway, switch, voip and etc.

Reply to
sailor.gu

To achieve re-use, you need to "abstract" away all the external interfaces such as file system, external h/w etc. and leave the "core algorithm / prime directive" of the component "clean".

I would love to give an example here, but it can't do the topic justice. Needless to say, it usually is not achieved in one's early years without some guidance. One powerful concept though is the use of "interface pointers". These are pointers to functions/services which provide the "generic" service the component needs, but are set-up at run time - this allows the component to not be changed when the underlying service/interface changes (different O/S, file system, etc.). This requires that the "host" software system of the component provide the system specific "porting layer", that your component would need.

JMHO, YMMV,

-D

Reply to
Mr_D

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.