oop

Are there any good (preferably free) OO modelling apps for Mac OS X?

I'm looking for something relatively simple to spec out a class hierarchy for C++. Can cost $ but preferably something free or at least simple and not overly feature laden and $$$. ...

How many types should be implementing the Repository pattern?

I am trying to use the repository pattern in an instance of storing pictures. What I do is save the actual pics in a directory on disk but save data about the pics and what pics go with what object in a database. I was wondering if I should use 2 interfaces for the storage, like IStorePicRepo and IStorePicDataRepo or have 1 interface ...

Where should I put my first method

Hello. I've a need to add method that will calculate a weighted sum of worker salary and his superior salary. I would like something like this: class CompanyFinanse { public decimal WeightedSumOfWorkerSalaryAndSuperior(Worker WorkerA, Worker Superior) { return WorkerA.Salary + Superior.Salary * 2; } } Is t...

Actionscript 3.0, why is it missing good OOP elements?

Anyone who has programmed with actionscript 3.0 has most certainly noticed its lack of support for private constructors and abstract classes. There are ways to work around these flaws, like throwing errors from methods which should be abstract, but these work arounds are annoying and not very elegant. (Throwing an error from a method tha...

How do I implement this type of OOP structure?

Hi, I want to build a nice API (C#) to make it easier for people to consume, I think I've seen this before and want to know how to do this: MyNamespace.Cars car = null; if(someTestCondition) car = new Honda(); else car = new Toyota(); car.Drive(40); Is this possible? If so, what needs to be done? ...

Why can't I subclass datetime.date?

Why doesn't the following work (Python 2.5.2)? >>> import datetime >>> class D(datetime.date): def __init__(self, year): datetime.date.__init__(self, year, 1, 1) >>> D(2008) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: function takes exactly 3 arguments (1 given) I wanted to c...

Are there any rules for OOP?

Hey all, Recently I heard that there are 9 rules for OOP(Java). I know only four as Abstraction, Polymorphism, Inheritance and Encapsulation. Are there any more rules for OOP? ...

Is the Factory pattern useful outside a framework without Visitor?

After some years of experience in the field, it seems to me that the Factory pattern is one of the less interesting and useful patterns around when not writing frameworks or libraries. I'm not saying that Factory pattern is unnecessary. For example, the W3C Document interface serves as a factory for various XML nodes (elements, attribut...

Main concepts in OOP

I was once asked in an interview 'What are the 3 main concepts of OOP?'. I answered by saying that in my opinion there were 4 which are as follows: Inheritance Encapsulation Abstraction Polymorphism Was I correct? ...

OO style parameters vs type parameters

Say you have these two methods: Number 1: void AddPerson(Person person) { // Validate person if(person.Name != null && IsValidDate(person.BirthDate) DB.AddPersonToDatabase(person); } Number 2: void AddPerson(string name, DateTime birthDate) { Person p = new Person(name, birthDate); DB.AddPersonToDatabase(person); } Wh...

Benefits of using a constructor?

Hi Guys, In my quest in trying to learn more about OOP in PHP. I have come across the constructor function a good few times and simply can't ignore it anymore. In my understanding, the constructor is called upon the moment I create an object, is this correct? But why would I need to create this constructor if I can use "normal" functio...

Why is accessing a static method from a non-static method bad?

Netbeans tells me it's bad to access a static method from a non static method. Why is this bad? "Accessing static method getInstance" is the warning: import java.util.Calendar; public class Clock { // Instance fields private Calendar time; /** * Constructor. Starts the clock at the current operating system time *...

What would you do if you coded a C++/OO cross-platform framework and realize its laying on your disk for too much due to no time?

This project started as a development platform because i wanted to be able to write games for mobile devices, but also being able to run and debug the code on my desktop machine too (ie, the EPOC device emulator was so bad): the platforms it currently supports are: Window-desktop WinCE Symbian iPhone The architecture it's quite compl...

Why should I avoid multiple inheritance in C++?

Is it a good concept to use or I can do other things in place of this? ...

How to synchronize the same object on client and server side in client-server application? Is small messages framework good for this job?

Hi, I'm making a game engine in c++ and python. I'm using OGRE for 3D rendering, OpenAL for sound, ODE for physics, OIS for input, HawkNL for networking and boost.python for embedded python interpreter. Every subsystem (library) is wrapped by a class - manager and every manager is singleton. Now, I have a class - Object - this could be ...

Does One Persist XML/CSV/Other Through Repositories/Services/Other

I have an application that imports information from a CSV file or from a database and exports it to XML. This XML is currently being persisted to a file. However due to project needs I have decided it may be better to persist this XML to a database. Currently I have CSV, XML and SQL repositories that deal with importing/exporting data. ...

Polymorphism - Define In Just Two Sentences

I've looked at other definitions and explanations and none of them satisfy me. I want to see if anybody can define polymorphism in at most two sentences without using any code or examples. I don't want to hear 'So you have a person/car/can opener...' or how the word is derived (nobody is impressed that you know what poly and morph means)...

Warning signs for untestable code

Code that is untestable really annoys me. The following things make oo-code untestable: global states, e.g., the Singleton Design Pattern static methods that do some fancy work e.g database access deep inheritance tree work in constructor e.g. control statements classes that violate the Single Responsibility Principle Are there more ...

How to implement property() with dynamic name (in python)

Hello together and a happy new year 2009! I am programming a simulations for single neurons. Therefore I have to handle a lot of Parameters. Now the Idea is that I have two classes, one for a SingleParameter and a Collection of parameters. I use property() to access the parameter value easy and to make the code more readable. This works...

Linq2Sql, OOP, DependencyInjection problem

I'm still struggling a bit with OOP concepts and dependency injection so bear with me. I have generated my Linq2Sql model with a User table and now I would like to be able to send a confirmation email to this user so I created a partial class file for my User object and I felt it was natural to add a SendConfirmationEmail() method to th...