oop

Python: Should I use a class or dictionary?

I have a class that contains only fields and no methods, like this: class Request(object): def __init__(self, environ): self.environ = environ self.request_method = environ.get('REQUEST_METHOD', None) self.url_scheme = environ.get('wsgi.url_scheme', None) self.request_uri = wsgiref.util.request_uri(e...

Can (should) I inherit parts of a function in R?

I have two functions that start pretty similarly. Hence I wonder if this is the right moment to dive into inheritance in R. firstfunc <- function(table,pattern="^Variable") { dframe <- get(table) cn <- colnames(get(table)) qs <- subset(cn, cn %in% grep(pattern, cn, value=TRUE)) ..... } secondfunc <- function(table,pattern="^st...

Linq-To-SQL Table Class Design

I'm using Linq-To-SQL for a project with around 75 tables. We have to keep a cache of entire tables that we pull down because the entities are all interrelated and pulling them on demand takes way too long. So, to track all of these entities from all of these tables, we have a single class responsible for maintaining in-memory table refe...

Why can't I access private class methods in the class's companion object in Scala?

I'm working on a homework assignment for my object oriented design class, and I'm running into trouble with Scala's companion objects. I've read in a few places that companion objects are supposed to have access to their companion class's private methods, but I can't seem to get it to work. (Just as a note, the meat of the assignment had...

What's the closest we can come to a definitive list of concepts and guiding principles in OO Software Design?

I'm hoping to assemble a definitive and useful study guide. Please help! I'll start: Program to an Interface not an Implementation Interface Separation Principle DRY Principle (Don't Repeat Yourself) Law of Demeter Liskov Substitution Principle Dependency Injection/Inversion of Control Separation of Concerns Loose Coupling Open Clos...

CLOS for Clojure?

Does there exist anything like CLOS (Common Lisp Object System) for Clojure? If there isn't, how hard would it be to write one? Thanks in advance. -- Eric Grindt ...

PHP - why I could't declare static const variable?

I would use them to implement factory pattern, for example: class Types{ static const car = "CarClass"; static const tree = "TreeClass"; static const cat = "CatClass"; static const deathstar = "DeathStarClass"; } And I would like to use them like: $x = new Types::car; Is it possible? And what if my class has parametr i...

Tips for simplifying UI with large data model?

Hello, I'm working on an app for iPhone, and the data model looks a little crazy - 16 entity types. Could you offer any advice for masking complexity like this from the user? I know all these need to be there, but I'm trying to make it look simple, cause otherwise people will not understand. The Tricks I have figured out so far: My ap...

Design pattern for object-relational mapping.

I have several related database tables and I would like to treat their rows as objects and their tables as something like lists. What are the considerations that I have to keep in mind (for instance, ensuring that the objects stay consistent with one another and with the database, lazy loading)? And what is a good design pattern for im...

Who should construct objects in this scenario?

I have the following class: class PluginLoader { public: PluginLoader(Logger&, PluginFactory&, ConflictResolver&); //Functions. private: //Members and functions }; Logger, PluginFactory and ConflictResolver classes are all interface classes which will be implemented in the application. I create the single PluginLoader obje...

Need Help Planning Architecture for Categorization Connundrum

Hi Folks, I have more of a "what-would-you-do" question than an actual coding question. It relates to a project I am currently working on. In this project, we are tasked with combining several marketplace APIs into one interface. Each API has its own unique way of categorizing products. The top-level parent categories for all the API...

Is it possible to overload Async Callbacks in GWT?

Hello, I have an overloaded query method on the server side. I wanted to know if I can overload the async callback, depending upon the method signature? Or is it advised to define two different asyncallbacks? These are my two methods o the server. public String fetchInADay(String startTime, String endTime) {} public String fetchInADay(...

WordPress Plugin Development using OOP

I am a newbie in Plugin Development. So please correct me, wherever I get wrong. I have a website which needs a Players Plugin with the following needs:- An Admin controllable form for Player registration, with some details of them. A listing page where all the registered players are to be shown. Registered Players can be deleted & ...

Running methods with returned objects.

I am brushing up on my non-framework Object Oriented PHP and decided to do a test. Unfortunately, while I understand the concept of calling methods from a class, this particular test is slightly more complicated and I don't know what the terminology is for this particular type of situation is. Test Create a PHP class that parses (unkno...

Is it better to take object argument or use member object?

I have a class which I can write like this: class FileNameLoader { public: virtual bool LoadFileNames(PluginLoader&) = 0; virtual ~FileNameLoader(){} }; Or this: class FileNameLoader { public: virtual bool LoadFileNames(PluginLoader&, Logger&) = 0; virtual ~FileNameLoader(){} }; The fir...

Some pointers in designing an OO package to link into an exisiting system

Hey everyone, I'd like a few pointers as to a very specific situation i'm in regarding desigining and implementing a package in Java in an object-oriented manner. I hope i can get the idea across in a clear and not so sophisticated manner - or maybe not. Any ideas on useful design patterns to look at? Here goes.. The outline of the pr...

What is the canonical way of handling different types in Python?

I have a function where I need to generate different output strings for another program I invoke, depending on which type it wants. Basically, the called program needs a command line argument telling it which type it was called with. Happily I found this answer on SO on how to check a variable for type. But I noticed how people also ra...

The purpose of interfaces continued

OK so I gather that Interfaces are a way to enforce that an object implements a certain amount of functionality, without having to use inheritance. Kind of like a contract. And I semi see the point of them. But if all you have in the interface is: public interface animal{ void eat(object food); } and it has no implementation a...

When designing something in OO..

..where do you begin? As a basis for any design - for instance a package - where do you as a developer start. I start by mapping out the requirements and breaking them down into sub categories and from this objects and methods. Usually takes a while before I start drawing it out by hand - then that goes through a few versions. But I a...

Splitting objects into their most fundamental parts..

Not sure if the title captures what I'm trying to say here. When designing in OO should I be splitting my objects up into their most specific areas - so if I have a factory object that deals with creating objects but later on i come across a way of creating objects for another purpose even though they may be the same objects is it worth...