oop

Creating an extensible properties class (OOP)

I have an application which supports multiple types and versions of some devices. It can connect to these devices and retrieve various information. Depending on the type of the device, I have (among other things) a class which can contain various properties. Some properties are common to all devices, some are unique to a particular devi...

Magento: externally get relative URL's to categories.

I'm building a website, and installed Magento in the /shop/ subdirectory. I'd like to integrate the top categories into the menu of my non-Magento site, so you can navigate directly into the category. For this I need the category names and url's. Magento's categories are: Templates Color Theme General Other products I first needed...

How to design many-to-many relationships in an object database?

I thought it was about time to have a look at OO databases and decided to use db4o for my next little project - a small library. Consider the following objects: Book, Category. A Book can be in 0-n categories and a Category can be applied to 0-m Books. My first thought is to have a joining object such as BookCatecory but after a bit o...

How to get MATLAB to recognise newly added static methods?

I am using classes and static methods to 'scope' functions in a namespace, similar to C#. However, every time I add a new method to a class, at first it is not found. I have to restart the MATLAB environment (2007a) for the new methods to be recognised. Surely there is an 'update' or 'refresh' type command that I can use so that I do no...

What WinForm Control To Bind List(Of T)?

I have been working on keeping things object oriented for my project. Currently, I'm using a .DLL which supplies all of the app's classes to the WinForms project acting as the presentation layer. My .DLL will, for example, return a SortableBindingList(Of T) to code in a form. The SortableBindingList(Of T) comes from here. Let's assume a...

Architecting common and unique behaviour in code

I am designing a utility to backup applications. The backup functionality will contain both common tasks to do (common code) and some unique steps. Am I on the right track by using an interface for the unique behaviour and an abstract base class for the common behaviour in common by all the children? Is there any downside to this approa...

Can I create Java-like interfaces in Perl?

I understand that Perl's OO model is rather primitive; it is, in most respects, essentially a namespace hack. Nevertheless, I wonder if it is possible to create something like an "interface?" My goal is to have a base class from which others are extended whose principal purpose is to make mandatory the implementation of certain method...

Java Object Method Stack Frame Parameters

So in java, say you have a non-static method 'bar()' in an class 'Foo'. class Foo { private int m_answer; public Foo() { m_answer = -1; } public void bar(int newAnswer) { m_answer = newAnswer; } } Say then that you call this method like so: Foo myFoo = new Foo(); myFoo.bar(42); Now the...

Does my code smell? Lots of empty, virtual methods

I have a class "Shape" which is a supertype of many other "shapes" in my app. I have lots of empty methods on the Shape class which are declared as virtual / overridable, so there is not really any default bahaviour. Of course, some sub-shapes implement these methods. I am really just using it so that I can treat all my shapes as Shape...

jquery class inheritance

var A=function(){ }; $.extend(A.prototype, { init:function(){ alert('A init'); } }); var B=function(){ }; $.extend(B.prototype,A.prototype,{ init:function(){ alert('B init'); } }); var p=new A(); p.init(); var x=new B(); x.init(); is the above the best way to create class and inheritance in jQuery? In B's init how do I invok...

AIR javascript class extension - air.URLLoader and static events

I am using multiple asynchronous air.URLLoader objects, and would like the events fired to be aware of the urlloader's "myId". The objects i am downloading have ids per se, so i'd like to know in my event listener callback function from which download id the progress/finished/error event came. code: # loader addonLoader = new air.URLLo...

OOP. Choosing objects

I'm a relative newbie to thinking in OOP terms, and haven't yet found my ‘gut instinct’ as to the right way to do it. As an exercise I'm trying to figure out where you'd create the line between different types of objects, using the drinks on my desk as an example. Assuming I create an object Drink, that has attributes like volume and te...

Arguments for duck-typing in a strongly-typed OOP language?

Is there a case where you wrote something in such a language (e.g. C#, Java), and missed duck typing? (See this question for arguments against duck typing) ...

Which is more evil: an unnecessary singleton or a God Object?

Here's the situation: I've got a class that is doing too much. It's mainly for accessing configuration information, but it also has the database connection. It's implemented as a singleton, so this also makes unit testing it difficult as most code is pretty tightly coupled to it. This is even more problematic as it creates an import-...

Is there such thing "the best abstraction" for a given design problem?

This question is regarding object oriented design. It may fit into community wiki. Usually , when one design a set of classes which communicate with each other through interfaces , he ask himself , what Interfaces should I make? How to abstract various sub-components in the system in order to achieve the design goals. If we put aside p...

Pattern for objects initialization at startup

I'm building an application and as time goes on, I have more and more objects to initialize at startup. Moveover, some of the newer objects depend on others so I'm getting some kind of spaggetti initialization where objects are created then passed to other constructors. I'm suspecting that I'm getting it wrong. For example I have a WinF...

Architecture of some reusable code

I am writing a number of small, simple applications which share a common structure and need to do some of the same things in the same ways (e.g. logging, database connection setup, environment setup) and I'm looking for some advice in structuring the reusable components. The code is written in a strongly and statically typed language (e....

Building Object in Rebol dynamically

This works: >> Oblock: [FirstName: "" [ LastName: "" [ BirthDate: ""] == [FirstName: "" LastName: "" BirthDate: "" ] >> Person: Make Object! OBlock >> Person >> probe Person make object! [ FirstName: "" LastName: "" BirthDate: "" ] >> Person/FirstName == "" >> Person/FirstName: "John" == "John" But this doesn...

What's the meaning of ORM?

Hi All! I ever developed several projects based on python framework Django. And it greatly improved my production. But when the project was released and there are more and more visitors the db becomes the bottleneck of the performance. I try to address the issue, and find that it's ORM(django) to make it become so slow. Why? Because Dja...

Protected Constructors and MustInherit/ Abstract class

What is the difference between a class with protected constructors and a class marked as MustInherit? (I'm programming in VB.Net but it probably equally applies to c#). The reason I ask is because I have an abstract class that I want to convert the constructors to shared/static methods. (To add some constraints). I can't do this becaus...