oop

Extend No-Constructor class

In C#, is it possible to extend a class that has no constructors? Maybe I'm thinking about this incorrectly and just need a kick in the crotch. I have a Silverlight class that extends System.Windows.Media.Transform, With the official release of Silverlight 2, Transform now has no constructor. So, when I compile my class, I get an err...

Java Instantiation.

When an object is instantiated in Java, what is really going into memory? Are copies of parent constructors included? Why do hidden data members behave differently than overridden methods when casting? I understand the abstract explanations that are typically given to get you use this stuff correctly, but how does the JVM really do it...

Appending to an array variable in a parent class in PHP

How do I extend my parent's options array for child classes in PHP? I have something like this: class ParentClass { public $options = array( 'option1'=>'setting1' ); //The rest of the functions would follow } I would like to append to that options array in a child class without erasing any of the parent opt...

Is there a "right" way to do inheritance in JavaScript? If so, what is it?

I have been trying to learn how to add testing to existing code -- currently reading reading Working Effectively With Legacy Code. I have been trying to apply some of the principles in JavaScript, and now I'm trying to extract an interface. In searching for creating interfaces in JavaScript, I can't find a lot -- and what I find about ...

Design questions for an OOP library in Lua

I implemented a small OOP library in Lua, and two things are not quite right yet. I need your advice! How to call super()? I need to make a choice. The three arguments I need to resolve a call to super() are: The class from where the call is being made (CallerClass) The instance to be passed (self) The name of the method (method) ...

A little help with class hierarchy

Okay I need a little help, mainly because what I've done feels messy but I can't think of a another solution that fits better. I'm writing a MUD engine and I've just started on the game object model, which needs to be extensible. Now I have a class called MudObject, and another class called Container, A container can contain multiple M...

Exposing an enum from a library class

In C#, I am using a library that defines an enum. I would like to allow consumers of my code (in a different assembly) to pass in an enum value as a parameter to one of my functions without having to reference the underlying library themselves. Is there a way for me to expose the library's enumeration to my consumers? ...

What is the exact problem with multiple inheritance?

I can see people asking all the time whether multiple inheritance should be included into the next version of C# or Java. C++ folks, who are fortunate enough to have this ability, say that this is like giving someone a rope to eventually hang themselves. What’s the matter with multiple inheritance? Are there any concrete samples? ...

What is "loose coupling?" Please provide examples.

I can't seem to grok the concept of "loose coupling." I suppose it doesn't help that the word "loose" usually has a negative connotation, so I always forget that loose coupling is a good thing. Will somebody please show some "before" and "after" code (or pseudocode) that illustrates this concept? ...

OOP and DataTables for Rank Amateurs

I'm a total amateur writing a small App to track to changes in folders. I imagine I'll be keeping information about the directories to watch in one datatable bound to a gridview, when the user clicks a button, the program will create FileSystemWatchers to keep an eye on the directories and they will send their event messages to another d...

How to avoid Anemic Domain Models and maintain Separation of Concerns?

It seems that the decision to make your objects fully cognizant of their roles within the system, and still avoid having too many dependencies within the domain model on the database, and service layers? For example: Say that I've got an entity with a revision history, and several "lookup tables" that the data references, your entity ob...

Java implementations of the Prototype Pattern

What implementations of the Prototype Pattern exist on the Java platform? A prototype pattern is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. Prototype based programming: Prototype-based programming ...

Class design for serialization - ideas or patterns?

Let me begin with an illustrative example (assume the implementation is in a statically typed language such as Java or C#). Say you are building a content management system (CMS) or something similar. The data is hierarchically organised into Folders. Each folder has a collection of children; a child may be a Page or a Folder. All items...

__destruct visibility for PHP

Should the "visibility" for the __destruct function be public or something else? I'm trying to write a standards doc for my group and this question came up. ...

Mapping strongly-typed DataSets in a generic FillDataSet method in C#?

Edit: I am using SqlDataAdapters to fill the data sets. Sorry--I should have been more clear. I'm working on a project where I need to fill a number of strongly-typed data sets with information from stored procedures. Right now, I have a generic method in my data access layer: public static DataSet FillDataSet(DataSet dataSet, string s...

Blending RDF and ORM approaches

I'm working on a team investigating a technology stack for a green-field systems integration project. Part of our favored technology stack use Hibernate to persist its internal state and exposes hooks into the Hibernate transactions so that business entities stay synchronized with the state of this utility. Great, except we need to maint...

What is a callback function and how do I use it with OOP

I want to use the php simple HTML DOM parser to grab the image, title, date, and description from each article on a page full of articles. When looking at the API I notice it has a set_callback which Sets a callback function. However im not sure what this does or how I would use it? In one of the examples its used to call a function whic...

What does it take to be a better OO programmer?

I’ve almost 6 years of experience in application development using .net technologies. Over the years I have improved as a better OO programmer but when I see code written by other guys (especially the likes of Jeffrey Richter, Peter Golde, Ayende Rahien, Jeremy Miller etc), I feel there is a generation gap between mine and their designs....

Aspect Oriented Programming vs. Object-Oriented Programming

Like most developers here and in the entire world, I have been developing software systems using object-oriented programming (OOP) techniques for many years. So when I read that aspect-oriented programming (AOP) addresses many of the problems that traditional OOP doesn't solve completely or directly, I pause and think, it is real? I hav...

Do polymorphism or conditionals promote better design?

I recently stumbled across this entry in the google testing blog about guidelines for writing more testable code. I was in agreement with the author until this point: Favor polymorphism over conditionals: If you see a switch statement you should think polymorphisms. If you see the same if condition repeated in many places in your cl...