oop

How to design an UML class diagramm with non object oriented parts?

Hi, i´m coding in ABAP and implemented a template method pattern. I like to draw some UML class diagramm for this. To do this in UML for the classes is no problem. But my class is implemented in a function modul (SAP specific terms), its like an stand alone method which i use to make the implementation available to an Remote Procedure C...

What all Programmers actually ever need..

I've coded quite a lot of projects both academically, personally, and commercially. And the one thing that always has seen me through is... Arrays. Sure you create structures or Objects (to put into those arrays), but in the end its held and manipulated via arrays. My question is do we really need anything else? Also on a similar v...

Field belongs to a class, but how to use polymorphism

I have a method in a base class class Base { private static string Colour = "blue"; string DoStuff() { return ColourProp; } protected virtual string ColourProp { get{ return Base.Colour; } } } that is called on an instance of this subclass class Sub { private static string Colour = "orange"; protected override string...

OO Programming Question: Global Object

Hi I have probably a quite simple problem but I did not find a proper design decision yet. Basically, I have 4 different classes and each of those classes has more than 10 methods. Each of those classes should make use of the same TCP Socket; this object keeps a socket open to the server throughout program execution. My idea was to hav...

Drawbacks of Context.Current Pattern?

For applications of any size, what are the drawbacks of using a Context.Current pattern? (i.e. "Current" is a shared/static property of a "Context" class that instantiates itself the first time it's used) Any advantage of using this pattern over just shared / static classes/methods? I'm asking in the context of .NET, although I guess i...

Is it possible to override a method in a class in a dll file?

I've included a dll file into my windows form project. 1. Is it possible to override a particular class entirely? 2. Is it possible to add a new method to a particular class in the dll file? 3. Is it possible to override a method in a class in the dll? Alternatives I would prefer to avoid: I know I can use extension methods to create st...

Object orientation and serialization

Consider an interface like IMyInterface = interface procedure DoSomethingRelevant; procedure Load (Stream : TStream); procedure Save (Stream : TStream); end; and several classes that implement the interface: TImplementingClass1 = class (TInterfacedObject, IMyInterface) ... end; TImplementingClass2 = class (TInterfacedObject, ...

When to use interfaces or abstract classes? When to use both?

While certain guidelines state that you should use an interface when you want to define a contract for a class where inheritance is not clear (IDomesticated) and inheritance when the class is an extension of another (Cat : Mammal, Snake : Reptile), there are cases when (in my opinion) these guidelines enter a gray area. For example, say...

Object Model Authorization - OO Design Question

Background Each Project has one Account it is associated with. Each User can have permission to access zero to many Accounts. This in turn means that each User can only access a sub-set of Projects based on the User's Account permissions. The User object is loaded up when the user signs in to the application, and Account permissions are...

What does this php construct mean: $html->redirect("URL")?

I've seen this "-> " elsewhere used in php. One of the books I used to learn PHP has this in it, but it is never explained. What does it do, how does it work! The redirect bit I know, but what is happening with the $html variable and the redirect function? Thanks in advance! ...

PHP Global Variables

I have a database class, which an instance is declared in the main index.php as $db = new Database(); Is there a way for the $db variable to be globally recognized in all other classes without having to declare global $db; in the constructor of each class? ...

What is a design of iChat?

iChat does not allow to change your credentials to your account when List window is open and you are connected to server. I am just wondering how this is implemented. I could imagine that internally iChat has some sort of ICAppDelegate that hold a pointer to ICPreferencesControler and an array of ICListWIndows. And now how preferences a...

what is a member vs. a property

A friend who is new to OO programming asked me the difference between a Member and Property, and I was ashamed to admit that I couldn't give him a good answer. Since properties can also be objects themselves, I was left with a general description and list of exceptions. Can somebody please lay out a good definition of when to consider s...

What's really happening with new and override under the covers?

I've found loads of practical examples of this, and understand the practical output when overriding or hiding methods, but I'm looking for some under the covers info on why this is and why C# allows it when according to the rules of polymorphism, this shouldn't be allowed - at least, insofar as my understanding of polymorphism goes (whic...

Is the null object pattern worth it ?

I was looking at the null object pattern and i am wondering if it worths implementing it or use "if" checks for nulls in my code intsead. As i looked at the implementations it seems hard to keep objects well synchronized with their null implementations. By making changes to the main object we have to check that the null object behaves as...

How can Inheritance be modelled using C?

Is it possible to model inheritance using C? How? Sample code will help. Edit: I am looking to inherit both data and methods. Containership alone will not help. Substitutability - using any derived class object where a base class object works - is what I need. ...

Cast from TObject to interface type

Hi, related to my last question, I now have the following problem: function TNodeFactory <T>.CreateNode (ID : Integer) : INodeInterface <T>; var NodeClass : TClass; begin NodeClass := FindRegisteredClass (ID); Result := NodeClass.Create; end; This yields a compiler error: E2010 Incompatible Types: 'INodeInterface<TNodeFa...

Tree structure with subclassed nodes, how to apply operation on a subset of children

I have a tree structure A -> B -> D -> Y -> C -> X -> X I want to do an operation on all objects of class X, or all the children objects of class D (for example). I want to call start this operation from any node in the tree (ie recursively). For e.g, A.SetupDecorators(); (although I'm open to suggestions) All classes i...

Is it possible in java to check has-a relationship?

In java we can use instanceOf keyword to check the isA relationship. But is it possible to check hasA relationship too? ...

RoR ActiveRecord dynamic finders: lying about interface?

Do Ruby on Rails' ActiveRecord dynamic finders have a problem in that they don't explicitly tell clients about their interface? Clients = client code or developers creating the client code. What uses the ActiveRecord. If you use the active record, is it clear from looking at the class what you can do with it, what it needs or how you ca...