oop

Attribute lists or inheritance jungle?

I've got 2 applications (lets call them AppA and AppB) communicating with each other. AppA is sending objects to AppB. There could be different objects and AppB does not support every object. An object could be a Model (think of a game, where models are vehicles, houses, persons etc). There could be different AppBs. Each supporting anoth...

segmentation fault by using virtual method in C++

Hello all, I got a C++ object oriented program that was working right. I have decided to modify it by adding some polimorpysm definining a class hierarchy with virtual methods. When I call the virtual method it produces an fault segmentation error, likely because I have trash in the object. This is the call and the warming up GPU...

Does it make sense to check variable before initalizie it?

Is there any advantage if i check if the object already exists in an language like php? /** * User object * @var My_Model_User */ protected $user = null; /** * Setup */ public function __construct() { if ($this->user === null) { $this->user = new stdClass(); } ...

IoC Container + Unit Testing

Is it ok to use a container to create the objects that are going to be tested? Or should I build them manually? ...

Delphi Interface Performance Issue

I have done some really serious refactoring of my text editor. Now there is much less code, and it is much easier to extend the component. I made rather heavy use of OO design, such as abstract classes and interfaces. However, I have noticed a few losses when it comes to performance. The issue is about reading a very large array of recor...

Class inheritance for GUI using wxpython

I have a very simple GUI that accepts two parameters and then calls three other classes whose names are DigitalFilter(), BeatByBeatVariables(), and GetSummaryOfWholeTest(). This is my first time writing up classes, and I need help with the syntax. Specifically, can you help me with inheritance? I want the GUI's class MainWindow(wx.Fra...

What is aggregation and delegation in PHP...?

Hi guys I was wondering what these terms are in php...I looked up google but couldn't find any good answers. I would appreciate if someone here can help me about it. Thanks a lot.!!! ...

A class that only has static data and methods to access these data. How to implement that properly?

I know that is a beginner's question. I'm new to java and and also to programming in general. Say I got a class that has only static data, example: class Foo { private static int x; } I want to use the class without instantiating any object. So I want to be able to do: Foo.setX(5); Foo.getX(); What is the best way to implement th...

Encapsulation in Javascript

I'm pretty new to Javascript, as my SO profile will attest. I've just been reading up on a few tutorials and come across something I don't totally understand in regards to Object Orientation and Encapsulation when applied with Javascript. The tutorial stated that Javascript objects can be declared like this: var myCustomObject = new O...

Method naming conventions. Should the method be named getX(), if the there's no corresponding setX() ?

Say I got an Employee class that has a hire date data member. This member only get set one time only and it is constant too. So it'll get initialised when the object is created. If I want the class to have a method that returns the hire date, what's better: getHireDate(); Or just: hireDate(); Am I thinking too much :D ? ...

Triangle class implementation

Hi! There is task to implement some triangle class with interface like this public interface Triangle { void moveApex(Point from, Point to); List<Point> getApexes(); void rotate(double angle); void setLocation(Point p); Point getLocation(); void setSize(Dimension d); Dimension getSize(); } Where Point and ...

When should types or members be declared static ?

The static modifier means that the type cannot be instantiated or a member cannot be associated with an instance. But whats the benefit of this restriction on instantiation and under what use case scenario should types/members be declared static ? ...

What is the difference between declaring javascript objects with var vs. with function?

I'm a confused newbie. I read in a tutorial that you create a javascript object like so: function myObject() { this.myProperty = "a string"; this.myMethod = function () { //Method code } } Then I read somewhere else that you create an object like so: var myObject = { myProperty: "a string", myMethod : fun...

The point of an Interface

Possible Duplicate: How will I know when to create an interface? I'm wondering about the point of using an Interface. Do you use Interfaces? If so, when do you decide to use them and when do you decide NOT to use them? I've currently got interfaces defined for my service layers and my repository layers, but I'm wondering i...

PHP: How do I add a parameter to an object reference?

I have an object called $object formed as follows: stdClass Object ( [PLAYER_ID] => 141 [STATUS_ID] => 16 [LOGIN_NAME] => mikemo21 [EMAIL] => [email protected] [PT_BALANCE] => 13775 ) I'd like to add a parameter to this, perhaps so it appears as follows: stdClass Object ( [PLAYER_ID] => 141 [STATUS_ID] => 16 [LOGIN_NAME] => mikem...

Is there such a thing as a class that shares aspects of both control and entity stereotypes?

I have a class called 'Inventory' that has two subclasses, 'Drink' and 'Condiment'. They are a part of a software system being developed for use in a hot drinks vending machine. Note that this isn't really going to be implemented, rather it is a piece of coursework for my Software Engineering class. Anyway, I'm having trouble deciding wh...

One big object or one small plus one big info object?

Hi, For a Ruby on Rails app, I'm having this Movie object which has several attributes. Pretty much every page needs to compare some movies to a full list of these movies sorted by ratings, so I used to cache this big sorted list. It was useful, because I could directly use this list of Movies and all their attributes without any other ...

Javascript: Object's this.var inside jQuery method

Hi, I can't figure this one out: I have a function, e.g. function test () { this.rating = 0; $j('#star_rating a').click(function() { alert(this.rating); }); } var foo = new test(); On click it alerts "undefined". What is wrong? Please help. ...

Refactoring Java Periodic Tasks

I'm try out a few game mechanics and I tried to mimic WoW's periodic events such as "x damage every z seconds". I've used Timers so far to schedule periodic tasks in this case where I'm trying to regenerate health but is it really necessary to pass "this" in order to modify the instance variable, _mana? Do I really need a separate TimerT...

What is the difference between float and float? return type in C# property

Possible Duplicate: What does DateTime? mean in C#? Hi All, I recently came across with some code in C# where float? is used as return type. I want to know what is the concept behind using this and in which scenario we need to use it against normal float return type. Thanks ...