oop

Stopping a function from been overridden in Delphi

How do I stop a function/procedure in a superclass from been overridden in a subclass in Delphi (2007)? I want to mark it so it can not be altered, I believe there is a final keyword but can not for the life of me find the documentation for it, so I am not 100% sure that's what I need. ...

public variables vs private variables with accessors

Has anyone else seen people do this: private string _name; public string Name{ get{ return _name; } set{ _name = value;}} I understand using accessors if you are going to exercise some sort of control over how it gets set or perform some sort of function on it when there is a get. But if you are just going to do this, why not just mak...

Aren't Information Expert / Tell Don't Ask at odds with Single Responsibility Principle?

It is probably just me, which is why I'm asking the question. Information Expert, Tell Don't Ask, and SRP are often mentioned together as best practices. But I think they are at odds. Here is what I'm talking about: Code that favors SRP but violates Tell Don't Ask, Info Expert: Customer bob = ...; // TransferObjectFactory has to use Cu...

Class property as a collection

Greetings, I need to include a property in my class which is a collection of System.IO.FileInfo objects. I am not really sure how to do this and how I would add and removed objects from an instance of the the class (I would assume like any other collection). Please let me know if I need to add more information. Thank you Update:...

Object-relational mapping: What's the best way to implement getters?

What should happen when I call $user->get_email_address()? Option 1: Pull the email address from the database on demand public function get_email_address() { if (!$this->email_address) { $this->read_from_database('email_address'); } return $this->email_address; } Option 2: Pull the email address (and the other User a...

Best way to use sessions with MVC and OO PHP

I've been working with sessions, MVC design and object oriented PHP. Where should I save or retrieve data from a session? I would like to retrieve it from within methods so I don't have to pass the data to the methods. Whats the best practice? ...

Interface "recursion" and reference counting

I have a small problem with interfaces. Here it is in Pseudo code : type Interface1 = interface end; Interface2 = interface end; TParentClass = class(TInterfacedObject, Interface1) private fChild : Interface2; public procedure AddChild(aChild : Interface2); end; TChildClass = class(TInterfacedObject, Interfa...

Visitor Pattern + Open/Closed Principle

Is it possible to implement the Visitor Pattern respecting the Open/Closed Principle, but still be able to add new visitable classes? The Open/Closed Principle states that "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification". struct ConcreteVisitable1; struct ConcreteVisitabl...

When you are abstracting your database records and datasets into objects, what does your object model look like?

I'm asking all of you who aren't using a library for this, but are constructing your own objects for managing data flowing to and from your database tables. Do I have a recordset object? one object per row of data? Both? Neither? Any suggestions or experiences welcome. Please don't tell me to use an ORM or other such toolkit. It's ov...

Ruby and duck typing: design by contract impossible?

Method signature in Java: public List<String> getFilesIn(List<File> directories) similar one in ruby def get_files_in(directories) In the case of Java, the type system gives me information about what the method expects and delivers. In Ruby's case, I have no clue what I'm supposed to pass in, or what I'll expect to receive. In Ja...

OO Design: Multiple persistance design for a ruby class

Hi all, I am designing a class for log entries of my mail server. I have parsed the log entries and created the class hierarchy. Now I need to save the in memory representation to the disk. I need to save it to multiple destinations like mysql and disk files. I am at a loss to find out the proper way to design the persistence mechanism....

What should be OO and what shouldn't?

I've read a lot of people saying that some things shouldn't be written in an object orientated style - as a person learning the OO style coming from a C background, what do they mean by this? What shouldn't be OO, why do some things fit this design better, and how do we know when it's best to do what? ...

Which PHP CMS has the best architecture?

In your opinion, which PHP CMS has the best architecture? I don't care about how easy its admin panel is to use, or how many CMS features it has. Right now, I'm after how good its code is (so, please, don't even mention Drupal or Wordpress /shudder). I want to know which ones have a good, solid, OOP codebase. Please provide as much de...

Designing Game Objects

I recently started working on a small game for my own amusement, using Microsoft XNA and C#. My question is in regards to designing a game object and the objects that inherit it. I'm going to define a game object as something that can be rendered on screen. So for this, I decided to make a base class which all other objects that will nee...

Website to practise OOP design skills...

Is there a website/list of problems which can be used to practice OOP design skills? Let's say if I am a colleague graduate familiar with object-oriented-design theory, these problems should give me a chance to exercise the theory and improve my software design skills. ...

Passing copy of object to method -- who does the copying?

I have an object that I'm passing in a method call. Say I'm using a language that only allows you to pass objects by reference, like Java or PHP. If the method makes changes to the object, it will affect the caller. I don't want this to happen. So it seems like I need to make a copy of the object. My question is: whose responsibility is...

Access parent's parent from javascript object

Somthing like var life= { users : { guys : function(){ this.SOMTHING.mameAndDestroy(this.girls); }, girls : function(){ this.SOMTHING.kiss(this.boys); }, }, mameAndDestroy : function(group){ }, kiss : function(group){ } }; this.SOMTHING is what I imagine the format is, but it m...

What, exactly, distinguishes between private and protected (in Flex)?

In Flex (and many other languages) a function/method of a class can be declared private or protected (or public). What's the difference? I have the impression it has something to do with the relationship to child classes and how things are inherited or can be called, but I'm not sure what, exactly. ...

How do I create a copy of an object in PHP?

It appears that in PHP objects are passed by reference. Even assignment operators do not appear to be creating a copy of the Object. Here's a simple, contrived proof: <?php class A { public $b; } function set_b($obj) { $obj->b = "after"; } $a = new A(); $a->b = "before"; $c = $a; //i would especially expect this to create a cop...

What's is a good ratio of Class to Lines of Code for Object-Oriented languages?

What's is a good ratio for the number Classes to Lines of Code for an Object-Oriented language (say C++,C#,Java and their likes)? Many people, including managers, like the traditional LOC (lines of code) metric to measure the complexity of software, while many hard-boiled Object Oriented developers will say LOC is worthless its Class co...