oop

Dividing lines between Session Object, User Object, and Login Controller.

I'm developing my own PHP framework, and I'm trying to do things more "by the book". I want to build login system. I have done this plenty of times, but now I just want to confirm/get some feedback on a system. I know we need... A Session Object A User Object A Login Controller What my question is, is who holds what power? Here's ...

When to use Data Transfer Objects and DataSets

I'm trying to come up with a methodology for when to use Data Transfer Objects and when to use DataTables. As an example of the problem I'm facing in our system... We have 6 different business entity assemblies representing the same things but with different properties. They have been created by several developers concerned with diffe...

How can I implement my LayoutManager without instanceOf?

For a certain layout that I'm working on, I need to make my own LayoutManager. It will lay out different components depending on what type they are: Labels in one way, Separators in another way, and everything else in a third way. I can easily implement this and to determine the different positions for different types of components, i...

Passing Interface's method as parameter

Hi, is it possible to pass inetrface's method as parameters? I'm trying something like this: interface type TMoveProc = procedure of object; // also tested with TMoveProc = procedure; // procedure of interface is not working ;) ISomeInterface = interface procedure Pred; procedure Next; end; TSomeObject = class(TO...

OO design - propagating attributes

Hi, I'm an experienced C programmer dipping my toes in OO design (specifically C++). I have a particular piece of code I hate and would like to clean up using C++. The code implements a display tree for use in a 3d graphics app. It is a linked list of entries which have a type field specifying whether the entry is a window, geometry fea...

Issue with component creation: field ends up nil

This is a continuation of the project I was working on here: http://stackoverflow.com/questions/692173/circular-reference-issue-with-classes-which-use-each-other The advice received there fixed the ciruclar reference problem (again, thanks for the help). Now I'm wrestling w/something else: TcmDataPanel.FObservingDataPanels always ends...

References for thinking Objected Oriented

I would like to start thinking in Object Oriented ways. What are the top books and online resources? I saw this post for the TOOTP 3rd edition, is that the best way to change my thought process of programming? Thanks! ...

How do you hide encapsulation in C#?

Socket.Dispose() is an inaccessible member. However, we can bypass this by doing the following: ((IDisposible)Socket).Dispose() Two questions: Why is this allowed? How does this work internally? ...

How to make a base class method non-overridable in ruby?

I have some base class A with a method that is not to be overridden. class A def dont_override_me puts 'class A saying, "Thank you for not overriding me!"' end end And another class B that extends A and tries to override the dont_override_me method. class B < A def dont_override_me puts 'class B saying, "This is my impl...

Why is it good practice to return at the end of a method

A fellow programmer asked me why should we always return at the end of a method? We had both be taught to always have only a single return statement in a method and not multiple scattered throughout the code. Any good reasons for this? ...

how do I delete/gc an object in Actionscript 3?

I want to delete/force garbage collection on a class instance from inside itself. Obviously, this = null and delete this don't work. Is it any way I can do that, or am I barking up the wrong tree? I'm basically looking for a destructor of some sort.. I have a class instance that attempts to load an XML file, and if the file is not found...

Class attribute declaration: private vs public.

What are the advantages of defining a private attribute instead of a public attribute? Why should I have the extra work of creating methods to access and modify privates attributes if I can just make them public? ...

Creating objects without breaking encapsulation

I'm fairly new to all this, so this is probably OOP 101 but I can't get my head around it, assume the following C# code lives in an assembly: internal interface IDataStore { void Store(string name, object data); object Retrieve(string name); } internal class DBStore : IDataStore { public DBStore(string connection) { } p...

Anonymous vs named inner classes? - best practices?

I have a class, let's call it LineGraph, that renders a line graph. I need to subclass it, but the derived class is only used in one place and is coupled to the class that uses it. So I am using an inner class. I see two ways to do this: Anonymous inner class public class Gui { LineGraph graph = new LineGraph() { // extra ...

OOP/OOD Book Suggestions (.NET-focused) For Office Library

Our office is about to finally spend some more money updating the in-house reference library and I suggested that we pick up some more books that focus on Object Oriented Programming/Design from a .NET perspective (which is what we focus in, primarily VB and ASP.NET). After doing a quick look through our current shelf we seem to only ha...

Why do dynamic languages like Ruby and Python not have the concept of interfaces like in Java or C# ?

To my surprise as I am developing more interest towards dynamic languages like Ruby and Python. The claim is that they are 100% object oriented but as I read on several basic concepts like interfaces, method overloading, operator overloading are missing. Is it somehow in-built under the cover or do these languages just not need it? If t...

Member function vs. nonmember function?

What is your rule for which functions that operate on a class should be member functions vs. nonmember functions? For example, I have a class which represents a maze using a matrix of bools. I am making a function called isConnected which verifies that 2 points in the maze are in the same region (i.e. it is possible to travel from A to B...

Why Use PHP OOP over Basic Functions and When?

There are some posts about this matter, but I didn't clearly get when to use Object Oriented coding and when to use programmatic functions in an include. Somebody also mentioned to me that OOP is very heavy to run, and makes more workload. Is this right? Lets say I have a big file with 50 functions, why will I want to call these in a cl...

Social Network Application Design

Hello, I'm trying to determine the best design for an application that will access several different social network APIs. Here is an interface that I haven't settled on because it just doesn't feel quite right. I'd like to know what would be a better design approach to this problem... public interface ISocialNetworkAPI<TApiEntity> whe...

High level design pattern for image editing tools

I have recently begin creating an image editing tool which will cater to a very specific need. This is as much for the people who are going to use it as it is for my own entertainment. however, I have hit a bit of an architectural snag early on. Like any image editor, the user will use 'tools' to draw on and manipulate an image. My...