oop

How to override methods in Coldfusion (adding and changing arguments etc.)?

I have two almost identical Beans. Bean "Item" contains a unique identifier (primary key), a name and an array that contains structs with data for different Users that are related to the "Item". Bean "User" contains a unique identifier (primary key), a firstname, a lastname and an array that contains structs with data of different Item...

Good tool for system design in Java/Eclipse?

Does anyone know of a good tool for laying out class diagrams and the like for eclipse? Preferably soemthing that will let me draw up the relationships between the classes/interfaces and will then generate stub code for me to fill in. I've just been handed a 288 page API doc and told to implement it in Java and I want to make sure I h...

Is it possible to create static field on base class but affect like creating on child class?

I need to create base class like the following code. public class ResourceBase { protected static IDictionary<string, XDocument> resources; protected static IDictionary<string, XDocument> Resources { get { if (resources == null) { // cache XDocument instance in resourc...

Using parent variables in extending class

Hi, I have three classes MainClass, Member, and Project. Member and Project extend the MainClass. First I create a MainClass object, then a Member object and execute the function setMember: $mainclass = new MainClass(); $member = new Member($id); $mainclass->setMember($member); When the $member variable is set to the current member ...

How to approach design problems like "design a vending machine"

Hello, I wanted to know what are the steps that I should follow to approach problems like design a vending machine and come up with a number of design documents (like use case, sequence diagram, class diagram). Is there any source/link that I can read where it talks about how to go step by step. Thanks. ...

Javascript this does not point to right object

Sample code: function TestClass() { this.init = function() { this.updateHeader(); // <-- error line }; this.updateHeader = function() { console.log("Works"); }; }; var test = new TestClass(); $(document).ready(test.init); When I run that in Firefox 3.5, Firebug gives me an error, saying that this.updateHeader is not a valid fun...

OO design patterns to use for validation

I am in the process of writing some validation code based on these assumptions: Validation code must be in an external class i.e. no data class contains it's own validation The same object can be validated in different ways e.g. validate syntax only; validate against DB look-ups; validate against duplicates; etc Validation output c...

Getting correct "this" in jQuery button callback

I have a class: function RustEditor() { this.init = function() { var saveButton = this.container.find("button.saveButton"); saveButton.click(function(){this.save();}); }; ... When I click the button, it complains that this.save is not a function. This is because "this" does not refer to the instance of RustEditor here, but to the...

c#: Inherited/interface static member?

Is there a way to require that a class have a particular abstract member? Something like this: public interface IMaxLength { public static uint MaxLength { get; } } Or perhaps this: public abstract class ComplexString { public abstract static uint MaxLength { get; } } I'd like a way enforce that a type (either through inher...

book that goes over loosely coupled oop designs like IOC etc.

Hi, Are there any books focused on the current trends of design? like IOC, lously coupled architectures etc.? I'm not sure if these are pure design patters per say... (C# preferred but not really a big deal) ...

How to teach object oriented programming to procedural programmers?

I have been asked to begin teaching C# and OO concepts to a group of procedural programmers. I've searched for ideas on where to begin, but am looking for general consensus on topics to lead with in addition to topics to initially avoid. Edit I intend to present information in 30 minute installments weekly until it no longer makes sens...

Eliminating multiple inheritance

I have the following problem and I'm wondering if there's a nice way to model these objects without using multiple inheritance. If it makes any difference, I am using Python. Students need contact information plus student information. Adults need contact information plus billing information. Students can be adult students, in which cas...

using mysqli to extract custom data

I am using a function in php for all select queries so that i can dynamically retrieve data from my database ..... I just wanted to know that is my code secure and efficient or if their is a better way to do this, if so please point me to the right direction...thanks class mysql { private $conn; function __construct(){ $this->co...

when to use a Singleton?

Possible Duplicate: Singleton: How should it be used Hi all, I am new to .net and in programming too. I want to that what is the real time scenario when one should use singleton design pattern. Thanks in advance, Anant ...

C# call function based on subType of object

I am confused by C# right now. I have a bunch of classes, say A, B, and C, which all derive from class "Parent". I have a function which takes an argument of type Parent, and depending on which child class the object it is called with is, I want it to call a different method. Currently, I am thinking using a dictionary mapping types...

Achieving Interface functionality in C++

A big reason why I use OOP is to create code that is easily reusable. For that purpose Java style interfaces are perfect. However, when dealing with C++ I really can't achieve any sort of functionality like interfaces... at least not with ease. I know about pure virtual base classes, but what really ticks me off is that they force me in...

What is F# lacking for OO or imperative?

Many times I hear that F# is not suited to particular tasks, such as UI. "Use the right tool" is a common phrase. Apart from missing tools such as a WinForms/WPF/ORM designer, I'm not sure what exactly is missing in F# -- honestly! Yet, particularly with UI, I'm told that C# just does it better. So, what are the actual differences and ...

How to call the construct of a ReflectionObject and how to get this from a ReflectionClass

I have an array of reflectionClasses. I need to get a reflectionObject from one of these and then call its constructor with some parameters. The point is to instantiate an object without knowing the class name (i'll know it at runtime). Example, just to render the idea: foreach (Conf::get_array() as $reflection_class) { //it's n...

What design pattern and strategy for a Request base system for actions [C#, PHP]

Hi all, I am doing a RogueLike game, and would like to make the logic for each entity modular. This probably could apply to web applications where there are roles and permission control too. The idea is to have something like this - we have different type of entities in the game. a door can be bashed down, while a stone wall cannot be ...

Object hierarchy vs. "case" statements

Consider a web form with a dropdown. Based on the selection in the dropdown, some options are displayed - not many, say two or three for each selection. When the user clicks OK, the server creates a new object, type determined by the dropdown, attributes from the appropriate options. So the server has to do three things based on the d...