Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #8834
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder4.news.weretis.net!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!reader02.news.zen.co.uk.POSTED!not-for-mail |
|---|---|
| From | Nobody <nobody@nowhere.com> |
| Subject | Re: Many forward reference in the code. Is it a ugly design? |
| Date | Sun, 14 Aug 2011 10:32:04 +0100 |
| User-Agent | Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) |
| 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> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Lines | 19 |
| Organization | Zen Internet |
| NNTP-Posting-Host | cec5a7ae.news.zen.co.uk |
| X-Trace | DXC=0hI6P6O^e?Zd]c;>LNFRcSYjZGX^207P[`<MJMoM3PF]XV>Kdf_fY[\NQ<`Sf8^Ta_0f79kM1KPAWO^>2jRX?:UY |
| X-Complaints-To | abuse@zen.co.uk |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c++:8834 |
Show key headers only | View raw
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