Connecting Tech Pros Worldwide Forums | Help | Site Map

design patterns

Jean-pierre Martineau
Guest
 
Posts: n/a
#1: Mar 1 '06
how apply design patterns to c ?
Zero
Guest
 
Posts: n/a
#2: Mar 1 '06

re: design patterns



Jean-pierre Martineau schrieb:
[color=blue]
> how apply design patterns to c ?[/color]

First you have to switch to C++,
haven't you?

Vladimir S. Oka
Guest
 
Posts: n/a
#3: Mar 1 '06

re: design patterns



Zero wrote:[color=blue]
> Jean-pierre Martineau schrieb:
>[color=green]
> > how apply design patterns to c ?[/color]
>
> First you have to switch to C++,
> haven't you?[/color]

Not necessarily. It is possible to do OO in C as well. Some of the
early C++ compilers were actully just producing C code for the
underlying C compiler.

This, however, still does not make the OP topical here. The
comp.programming group might be a better place to start.

--
BR, Vladimir

srikanth
Guest
 
Posts: n/a
#4: Mar 1 '06

re: design patterns


use #include<graphics.h>
with the help of pre definedfunctions you get required graphics
there will also be examples given in help menu

srikanth
Guest
 
Posts: n/a
#5: Mar 1 '06

re: design patterns


use #include<graphics.h>
with the help of pre definedfunctions you get required graphics
there will also be examples given in help menu

srikanth
Guest
 
Posts: n/a
#6: Mar 1 '06

re: design patterns


use #include<graphics.h>
with the help of pre definedfunctions you get required graphics
there will also be examples given in help menu

Vladimir S. Oka
Guest
 
Posts: n/a
#7: Mar 1 '06

re: design patterns



srikanth wrote:[color=blue]
> use #include<graphics.h>
> with the help of pre definedfunctions you get required graphics
> there will also be examples given in help menu[/color]

LoL

--
BR, Vladimir

Jean-pierre Martineau
Guest
 
Posts: n/a
#8: Mar 1 '06

re: design patterns


Jean-pierre Martineau a écrit :[color=blue]
> how apply design patterns to c ?[/color]
the question was not very clear, i rewrite:
how implément design pattern in style of object oriented programming in c ?
I think it could be simulate Object oriented by subtitute heritance
style by agregation style.

what you think about that ?
Ian Collins
Guest
 
Posts: n/a
#9: Mar 1 '06

re: design patterns


Jean-pierre Martineau wrote:[color=blue]
> Jean-pierre Martineau a écrit :[color=green]
> > how apply design patterns to c ?[/color]
> the question was not very clear, i rewrite:
> how implément design pattern in style of object oriented programming in c ?
> I think it could be simulate Object oriented by subtitute heritance
> style by agregation style.
>
> what you think about that ?[/color]

Yes, OO in C can be done that way. The simplest way to represent an
object in C is to add appropriate function pointers to a struct.

--
Ian Collins.
Malcolm
Guest
 
Posts: n/a
#10: Mar 2 '06

re: design patterns





"Jean-pierre Martineau" <jpmart@dev.ath.cena.fr> wrote[color=blue]
> Jean-pierre Martineau a écrit :[color=green]
> > how apply design patterns to c ?[/color]
> the question was not very clear, i rewrite:
> how implément design pattern in style of object oriented programming > in
> c ?
> I think it could be simulate Object oriented by subtitute heritance style
> by agregation style.
>
> what you think about that ?
>[/color]
Really you are using the wrong language.

You can design some really elaborate schemes using C, like a function called
"void *queryinterface(Object *obj, char *name)", which returns a structure
full of function pointers implementing the given interface, given that the
object supports it. So a car might implement the "container", "moveable" and
"light source" interfaces.

However it soon gets very unwieldy. You really want a language that will
hide the internal operations for you behind some intutive syntax.



--
Buy my book 12 Common Atheist Arguments (refuted)
$1.25 download or $6.90 paper, available www.lulu.com


adampetersen75@hotmail.com
Guest
 
Posts: n/a
#11: Mar 2 '06

re: design patterns


Jean-pierre Martineau wrote:
[color=blue]
> how apply design patterns to c ?[/color]

Design patterns aren't tied to any particular implementation. Many of
the well-known design patterns (consider for example Visitor and
Factory Method) are however not meaningful in a C context; the problems
they solve simply doesn't exist in C.

That said, it is my belief that C programmers can benefit from the
growing catalogue of patterns and I have written an article series
about patterns in C.

My pattern implementations are not be based on techniques for emulating
object oriented features such as inheritance or C++ virtual functions.
In my experience, these features are better left to a compiler;
manually emulating such techniques are obfuscating at best and a source
of hard to track down bugs at worst. Instead, it is my intent to
present implementations that utilizes the strengths of the abstraction
mechanisms already included in the C language

For more details, you can read the series at
http://www.adampetersen.se/

Regards, Adam

George
Guest
 
Posts: n/a
#12: Mar 2 '06

re: design patterns


Thanks Adam, i've been looking all over the place for a good article
about patterns in C.

Imre Palik
Guest
 
Posts: n/a
#13: Mar 3 '06

re: design patterns


Jean-pierre Martineau <jpmart@dev.ath.cena.fr> writes:
[color=blue]
> how apply design patterns to c ?[/color]

Wich one? :-)

Anyway, here is my favorit (I use this even with C++):

Singleton.

data members = static data
private methods = static functions
public methods = global functions

ImRe
Closed Thread


Similar C / C++ bytes