My Computer Forum Computer Science Forum

Go Back   My Computer Forum > Computer Science Forum > Programming

Programming Programming Languages, Interpreters, and Compilers - Assembly, Declarative, Machine, Object Oriented, Iterative


Reply
 
LinkBack Thread Tools Display Modes
January 10th, 2009, 01:15 PM   #1
 
Joined: Dec 2007
Posts: 37
Object oriented design and the Observer pattern

Hello everybody. As the topic's title suggests, I have a problem implementing an observer pattern in my model-view-controller object oriented project. My due date is tomorrow, so I would really appreciate if anyone could help. The problem is I don't see how could I define a Microsoft predefined control as an Observer without rewriting it's entire code. The problem is I need to create a class that implements the IObserver interface, but at the same time it must inherit the Microsoft control class I need to use. To make things clearer, I need to make a ListView-like class that's (by inheritance, of course) a ListView class and a class that has the specified interface at the same time, but it is impossible to double inherit in C#, so I don't see how to make this work. It needs to be an Observer class so I can plug it in the Observer list, but it also needs to be a ListView class so I can add it normally to a form's control collection.. Appreciate your help!
milin is offline  
 

My Computer Forum is free to register and we welcome everyone!

January 10th, 2009, 07:16 PM   #2
 
Joined: Dec 2007
Posts: 232
Re: Object oriented design and the Observer pattern

Quote:
Originally Posted by milin
To make things clearer, I need to make a ListView-like class that's (by inheritance, of course) a ListView class and a class that has the specified interface at the same time, but it is impossible to double inherit in C#, so I don't see how to make this work.
You can't derive from more than one class in C#, but you can implement as many interfaces as you like:

Code:
class foo : MyParentClass, IMyInterface {
}
CRGreathouse is offline  
March 27th, 2018, 11:48 PM   #3
Junior Member
 
Joined: Mar 2018
Posts: 2
I a gee with CR Greathouse on that! I am new at C# , but learning pretty quickly!
klyliex3mef is offline  
Reply

  My Computer Forum > Computer Science Forum > Programming

Tags
design, object, observer, oriented, pattern



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Practicing Object-Oriented programming julien Programming 0 March 16th, 2013 04:42 AM
How do I randomly place an object on a map? Infinity Algorithms 11 May 7th, 2012 10:21 PM
WEB DESIGN Acheampong Web Design 4 February 14th, 2011 08:12 AM
Getting object-oriented programming right! CRGreathouse Programming 4 June 25th, 2008 10:24 AM





Copyright © 2018 My Computer Forum Forum. All rights reserved.