Sign in to follow this  

My friend is a stupid moron and cannot program

This topic is 4353 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, this time it's a question from my friend (my friend not being a metaphor for me). Though obviously, the fact that I'm asking for him means that I don't know the answer either... Anyways, the question is... in a fairly large system, with multiple large components, how exactly do the components go about talking to one another, and calling each other's methods? Does each one get passed a reference to every other component when it is instantiated? Does each one pass the message to the class that created everything, and communicate through that? Do you just go ahead and make them all singletons (my favourite method :))? Or do you have to implement some cunning and hardcore message passing scheme? What's the general way all of this stuff is done? Bear in mind this is all in the context of Java GUIs when replying :) Thanks muchly for your help, people.

Share this post


Link to post
Share on other sites
Well what they COULD do is that with the instancing they register themself, with a 'superclass' which globally known and handles every message they all send to eachother.

What you often see in User Interface, that they usually have a parent/child relationship (often defined when the class/object/component instanced). which also allowes them to synchronise.

I'm not familiar with the exact inner workings of COM (Component Object Model), but the interfaces that are all derived from the 'IUnknown' interface and all have there on GUID (Globally Unique ID) that is registered in the register of the OS. Somehow they can commune with eachother in some special way.

Hope this gives you more attachment point to look into.

Regards,

Xeile

Share this post


Link to post
Share on other sites
Quote:
Anyways, the question is... in a fairly large system, with multiple large components, how exactly do the components go about talking to one another, and calling each other's methods? Does each one get passed a reference to every other component when it is instantiated?

Sort-of. Interfaces are established that determine what other components a componet will communicate with. The host application is responsible for instantiatng a component and wiring it up with other components.

Have a look at this this explanation of the IoC design pattern.

Share this post


Link to post
Share on other sites
In large systems, the programmers need to define some sort of interface specifications to define how these components should communicate together. Large systems tend to be built by more than one programmer, so the development goes separately. Without interface specifications, there could be mismatching between the components, for example, component A needs a reference to and access to some functions in component B but component B is not built for it and when these two components are put together, the system crashes. You want to avoid this.

In case of COM/DCOM, for example, a function Release() is necessary to destruct objects, and that is part of the interface specifications. But it really is up to you.

Share this post


Link to post
Share on other sites
I don't know a whole lot about java, or programming in general, ut since it's Object oriented, my first instinct would be to swap addresses, but make sure that you have everything properly encapsulated. of course, all of your methods described work, including the cunning and hardcore message passing system, which is just silly, considering the simpler methods available.

Go with whatever you are most comfortable with, unless your looking for a challenge.

Share this post


Link to post
Share on other sites
It's different depending on the context.
In the case of a GUI-system I'd keep a masterclass that all controls were children of. The masterclass (a dialog window for example) would then be able to query the direct children for data. If data is needed for subchildren it should still pass through the hierarchy, up through the direct children.
Child controls should never be able to communicate directly, and since the master object is in control they never have to. The programmer knows what data is needed, and can implement the needed algorithms in the master object.

Share this post


Link to post
Share on other sites
Hmm, so I guess it is as I thought, there isn't really much of a standard way of doing this... Thanks for your thoughts though. I think he's going to go for a message handling class to forward on calls to functions in other classes and such like, this seems like the most elegant method presented.

Share this post


Link to post
Share on other sites
Yes, an event-based system is indeed one way to go, when coupled with a "bulletin board". Ie, you store the messages in a queue that all the controlls can access, and then they can just react to the ones concerning them.
Which is exactly the way Windows works.

Share this post


Link to post
Share on other sites

This topic is 4353 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this