473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

design patterns

how apply design patterns to c ?
Mar 1 '06 #1
12 4671

Jean-pierre Martineau schrieb:
how apply design patterns to c ?


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

Mar 1 '06 #2

Zero wrote:
Jean-pierre Martineau schrieb:
how apply design patterns to c ?


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


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

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

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

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

Mar 1 '06 #6

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


LoL

--
BR, Vladimir

Mar 1 '06 #7
Jean-pierre Martineau a écrit :
how apply design patterns to c ?

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 ?
Mar 1 '06 #8
Jean-pierre Martineau wrote:
Jean-pierre Martineau a écrit :
> how apply design patterns to c ?

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 ?


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.
Mar 1 '06 #9

"Jean-pierre Martineau" <jp****@dev.ath.cena.fr> wrote
Jean-pierre Martineau a écrit :
how apply design patterns to c ?

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 ?

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
Mar 2 '06 #10
Jean-pierre Martineau wrote:
how apply design patterns to c ?


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

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

Mar 2 '06 #12
Jean-pierre Martineau <jp****@dev.ath.cena.fr> writes:
how apply design patterns to c ?


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
Mar 3 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Don Vaillancourt | last post by:
Hello all, Over the years as I design more database schemas the more I come up with patterns in database design. The more patterns I recognize the more I want to try to design some kind of...
1
by: Jay | last post by:
The GOF text is widely considered the definitive book on the topic. Design Patterns: Elements of Reusable Object-Oriented Softare, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides ...
1
by: Josh28 | last post by:
Hi We are a group of two chaps just out of undergrad, we created a software to automate the use of Design Patterns. We have put it up at Source Forge--http://dpatoolkit.sourceforge.net/ The...
13
by: John Salerno | last post by:
Here are a few I'm considering: Design Patterns Explained : A New Perspective on Object-Oriented Design (2nd Edition) (Software Patterns Series) by Alan Shalloway Design Patterns C# by...
2
by: Carlo Stonebanks | last post by:
I have the infamous GoF Design Patterns boo - it's been sittin gon my shelf for years. I have a huge reading list and find this book a rather dry read and am always putting it off. I have...
22
by: Krivenok Dmitry | last post by:
Hello All! I am trying to implement my own Design Patterns Library. I have read the following documentation about Observer Pattern: 1) Design Patterns by GoF Classic description of Observer....
5
by: Ludwig Wittgenstein | last post by:
Other than the Design Patterns book, which book(s) is/are the best to learn object-oriented software design/architecture from ?
7
by: =?Utf-8?B?bWF2cmlja18xMDE=?= | last post by:
Hi, I would like to know more about design patterns and specifically using C#. Can any one recommend a good book? Thanks
5
by: macca | last post by:
Hi, I'm looking for a good book on PHP design patterns for a OOP beginner - Reccommendations please? Thanks Paul
10
by: vital | last post by:
Hi, I am designing the middle tier of a project. It has 6 classes and microsoft application data access block. The six classes are DBServices, Logger, ProjectServices ... etc. and all these...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.