Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #8834
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Subject | Re: Many forward reference in the code. Is it a ugly design? |
| Date | 2011-08-14 10:32 +0100 |
| Message-Id | <pan.2011.08.14.09.32.03.882000@nowhere.com> |
| Newsgroups | comp.lang.c++ |
| References | <74a4b057-7063-4944-8cb9-b6bc7559abd5@g5g2000prn.googlegroups.com> <j27g73$6f3$1@dont-email.me> <j27mbe$vhc$1@dont-email.me> <4f2a10a2-f3a8-4900-b7cd-784a84a655cc@v9g2000pri.googlegroups.com> |
| Organization | Zen Internet |
On Sat, 13 Aug 2011 23:48:44 -0700, KaiWen wrote: > Sorry, my english is not good. I'm a new hand. I use forward references to > break circular dependencies. It's just a smell when I wrote my class. I > felt it's not good when there are too many forward references. As you > said, I need a general rule. Is there any way (or pattern, if there is, > too happy) to avoid this. Too many circular dependencies tends to indicate a lack of modularity, every component needing to know the details of every other component. One way to eliminate such dependencies is by splitting a class into an interface (with no member variables and only pure virtual methods) and an implementation (which derives from the interface). E.g. rather than A having a reference to B and B having a reference to A, A has a reference to X, B is derived from X, B has a reference to A. These can be defined in the order X, A, B, with no circularity.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Many forward reference in the code. Is it a ugly design? KaiWen <wenkai1987@gmail.com> - 2011-08-13 20:33 -0700
Re: Many forward reference in the code. Is it a ugly design? Lynn McGuire <lmc@winsim.com> - 2011-08-13 22:42 -0500
Re: Many forward reference in the code. Is it a ugly design? KaiWen <wenkai1987@gmail.com> - 2011-08-13 21:27 -0700
Re: Many forward reference in the code. Is it a ugly design? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-14 05:54 +0000
Re: Many forward reference in the code. Is it a ugly design? KaiWen <wenkai1987@gmail.com> - 2011-08-13 23:56 -0700
Re: Many forward reference in the code. Is it a ugly design? "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-14 07:27 +0200
Re: Many forward reference in the code. Is it a ugly design? KaiWen <wenkai1987@gmail.com> - 2011-08-13 23:48 -0700
Re: Many forward reference in the code. Is it a ugly design? Nobody <nobody@nowhere.com> - 2011-08-14 10:32 +0100
Re: Many forward reference in the code. Is it a ugly design? KaiWen <wenkai1987@gmail.com> - 2011-08-14 05:13 -0700
Re: Many forward reference in the code. Is it a ugly design? Paul N <gw7rib@aol.com> - 2011-08-15 13:15 -0700
Re: Many forward reference in the code. Is it a ugly design? KaiWen <wenkai1987@gmail.com> - 2011-08-14 00:10 -0700
csiph-web