|
That worked, thank you very much
Kelly Ryan
|
|
|
|
|
Assumptions and constraints:
I am working with C++, Object-oriented design. I am using two layers - UI and domain layer which contains application logic.
Question 1.
Problem formulation:
At the architectural level I need to separate UI from the application logic. At the design level I am using a facade/controller object in the domain layer. To track the updates of the state of domain objects I use Publisher/Subscriber design pattern, so that domain objects remain decoupled from UI but UI objects received notifications when a domain object state changes.
Question:
Is Mediator pattern more appropriate for this purpose?
Justification:
The downsides of Publisher/Subscriber pattern:
a) Domain object is coupled to the Publish interface.
b) When moving UI to a difference process or a different remote computer in the network, the publishing logic must be changed.
c) UI objects are coupled to the Publisher.
How do I suggest applying Mediator (Mediator-Singleton)? (There may be several different Mediators serving this purpose.)
a) During initialization stage each object registers with the Mediator to either send or receive a message with a certain MessageID. (Since this specific Mediator is Singleton it can easily be made visible from all domain and UI objects.)
b) When state of the domain object changes, the latter sends a message to the Mediator to inform it about the change.
c) Mediator stores the received message in its storage and forwards the forwards the message to all listeners waiting for the corresponding MessageID.
This scheme achieves the separation of concers - concern of message passing is moved to a separate class instead of domain objects. All objects are decoupled except for the Mediator. This design supports the reuse, and can be easily extended to a network application. For network applications it is a concern of two Mediators in both computers to exchange the messages, thus the design is connection independent.
So why is it not used, but Publisher/Subscriber is used instead?
Question 2.
Problem formulation:
Separation of UI and domain objects is usually implemented with ONE facade/controller object in the domain layer. For example, see Craig Larman, "Applying UML and patterns".
Question:
Do I need a similar facade/controller object in the UI layer? I feel like I do, but I have not seen people suggesting it, so I may be wrong.
Justification:
If UI is moved to a remote computer then all requests from UI objects will go through network, hence, all UI will need to be changed to accomodate for TCP/IP requests.
When UI grows large, when we use Operating System SendMessage(.) etc. the UI becomes a mess if we don't have a control over the sequential order of messages.
Do I make sense with my solutions or there is something that I have missed? Would appreciate any suggestions.
Thanks!
Nick Kisialiou
0x2B | -0x2B
|
|
|
|
|
My response for Question 1
The Mediator design pattern gets used to coordinate communication between many colleagues. This would apply to your situation if that communication needed to exist. The Publisher-Subscriber pattern exists for one-way communication, from the Publisher to the Subscriber. From your description of the application, I agree that you have used the correct design pattern for the situation. However, you may need to reconsider your implementation since so much depends on your Publisher interface.
My response for Question 2
Your Publisher-Subscriber framework should handle this. Instead of publishing to a local object (in the same process), it uses some sort of IPC. How this gets done depends on your implementation. However, if you've defined your Publisher-Subscriber interfaces correctly, you should have the ability to replace the classes that implement intraprocess communication with interprocess communication. Many RPC frameworks exist; for a starting point, check out Wikipedia[^].
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi,
I am running into some problems with this ActiveX function, I use the Class View to generate the method, it is all done through Visual C++ Wizards. Everything compiles, so say I create a method through the wizard as follows:
void CTestCtrl::Testing(VARIANT* test)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
}
So I have not entered anything into the code.
Now I'm trying to access this function in Visual Basic .NET so I do the following
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim test123 As Object
AxTest.Testing(test123)
End Sub
When I run the VB program it crashes.
Any help would be greatly appreciated.
|
|
|
|
|
Have you got any info on the crash? A stack trace and the exception generated would be a bug help.
Steve
|
|
|
|
|
This is the error I'm getting
An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll
Additional information: Object reference not set to an instance of an object.
|
|
|
|
|
Can I have a look at the .ODL for the method in question (I want to see that attributes are in place).
Steve
|
|
|
|
|
My VB lets me down here but I suspect nothing is wrong. The Dim statement defaults to "Nothing" so all is probably working as it is meant to. I suspect is you changed to "As Object" to "As Integer" all would work well.
Steve
|
|
|
|
|
Here is the part of the ODL file, this is in the method part
[id(9), helpstring("method Testing")] void Testing(VARIANT* test);
I also tried putting the Integer value there, but the same problem.
|
|
|
|
|
I notice there are no attributes on "test". Given that you're using a pointer to a variant I would expect this to look like the following:
[id(9), helpstring("method Testing")] void Testing([in, out]VARIANT* test);
Steve
|
|
|
|
|
Thanks that fixed the problem. Thanks for everyones help.
|
|
|
|
|
Hello everyone!
I've been wanting to know how good/bad I'm doing as a programmer... Can any expert help me out? (You know, how I'm doing with coding conventions, comments, resource usage, etc.) Here's one of my latest programs: (I've asked a LOT of questions for this one :P )
Binary: www.sulfurmidis.com/mazzee-proto7-NORELEASE.zip (Open "MazzeeMaps.lmg" when it asks you for a map)
Source: www.sulfurmidis.com/Mazzee-source.zip
Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
There is always room for improvement. If you are interested to improve your code, you may look into:
Scott Meyers, "Effective C++", "More Effective C++", different editions.
Steve McConnell, "Code Complete", 2nd edition.
Bjarne Stroustrup, "The C++ Programming Language", 3rd edition.
Nick Kisialiou
|
|
|
|
|
RainbowWyrm wrote: Scott Meyers, "Effective C++", "More Effective C++", different editions
A real cool and effective book.
Hi 5 scott.
Jesus Loves <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background:#ffaaaa">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
very little hungarian notations used, somehow i like using it .
though c++ allows declaration of variables inbetween statements, i would prefer all variables declaration at start of the block.
some good practice like if(x==NULL) can be coded as if(NULL == x).
Some comments were not required. like //Set it.
These are few that i can comment on.
-Prakash
|
|
|
|
|
1) Remove all the global variables.
2) quite a lot of code replication. Refactor or Redesign.
3) Create a Dispatcher routine for class and do the forwarding for
keyboard events to appropriate routines each of them handling one type of event.
look back,think of extensibility also. What does it take for another person to easily add code
to your project? Iterate, rethink, look for better concepts,apply generic algorithms. use c++
standard library where you can.
Vipin - MVP
|
|
|
|
|
you were vipinasda right?
0x0400:
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
|
|
|
|
|
|
you could have changed your screen name right? why you created a new account? that means your message
count'd start again from 0.
0x0400:
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
|
|
|
|
|
hehe, no probs. I had an invalid email id associated with that screen name.
Vipin - MVP
|
|
|
|
|
VivekuniQ wrote: you were vipinasda right?
I believe you right!.. a suggestion if you don't mind please don''t make this forum lounge.. please..
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
do you think i should take him to lounge to say this? or you felt something about the dialogs i had with toxcct? anyway i'd try talking less in general.
0x0400:
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
|
|
|
|
|
VivekuniQ wrote: do you think i should take him to lounge to say this?
sorry for hurting you!.... no probs people like you here !
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
RainbowWyrm:
Thanks! I'll look them up on Sears next time I go!
some good practice like if(x==NULL) can be coded as if(NULL == x).
You mean that the second way is better? Why?
quite a lot of code replication. Refactor or Redesign.
You mean the movement functions? You know of a shorter way? TELL ME! I've been looking for that for ages!
Create a Dispatcher routine for class and do the forwarding for<br />
keyboard events to appropriate routines each of them handling one type of event.
For the game and map maker? Oops... I didn't know you could do events in non-dialog apps... How?
_T_H_A_N_K_S_ you all!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
Hello everyone!
I just want to know how to do OpenGL with MinGW/GCC... I don't want to use VC++ for this, because I want to be portable... But how do I open a window in std C++, and how to I get rid of these errors?:
C:\>g++ Lesson1.cpp<br />
Lesson1.cpp:12:60: gl\glaux.h: No such file or directory<br />
<br />
C:\>g++ Lesson1.cpp<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x31):Lesson1.cpp: undefined<br />
reference to `glViewport@16'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x40):Lesson1.cpp: undefined<br />
reference to `glMatrixMode@4'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x48):Lesson1.cpp: undefined<br />
reference to `glLoadIdentity@0'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x76):Lesson1.cpp: undefined<br />
reference to `gluPerspective@32'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x85):Lesson1.cpp: undefined<br />
reference to `glMatrixMode@4'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x8d):Lesson1.cpp: undefined<br />
reference to `glLoadIdentity@0'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0xa2):Lesson1.cpp: undefined<br />
reference to `glShadeModel@4'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0xcd):Lesson1.cpp: undefined<br />
reference to `glClearColor@16'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0xda):Lesson1.cpp: undefined<br />
reference to `glClearDepth@8'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0xe9):Lesson1.cpp: undefined<br />
reference to `glEnable@4'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0xf8):Lesson1.cpp: undefined<br />
reference to `glDepthFunc@4'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x10f):Lesson1.cpp: undefine<br />
d reference to `glHint@8'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x12c):Lesson1.cpp: undefine<br />
d reference to `glClear@4'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x134):Lesson1.cpp: undefine<br />
d reference to `glLoadIdentity@0'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x192):Lesson1.cpp: undefine<br />
d reference to `wglMakeCurrent@8'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x1cd):Lesson1.cpp: undefine<br />
d reference to `wglDeleteContext@4'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x672):Lesson1.cpp: undefine<br />
d reference to `ChoosePixelFormat@8'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x6d6):Lesson1.cpp: undefine<br />
d reference to `SetPixelFormat@12'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x725):Lesson1.cpp: undefine<br />
d reference to `wglCreateContext@4'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0x787):Lesson1.cpp: undefine<br />
d reference to `wglMakeCurrent@8'<br />
C:\DOCUME~1\DARTH_~1\LOCALS~1\Temp/ccEXbaaa.o(.text+0xabd):Lesson1.cpp: undefine<br />
d reference to `SwapBuffers@4'<br />
collect2: ld returned 1 exit status<br />
<br />
C:\>
Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|