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...
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...
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...
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...
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...
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
...
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...
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...
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...
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...
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...
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(...
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 & ...
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...
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...
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...
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...
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...
..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...
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...