select Table1.colID, Table1.colName,
(select * from Table2 where Table2.colID = Table1.colID) as NestedRows
from Table1
The above query gives you this error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used.....
Can anybody explain why this limitat...
I have two classes that each need an instance of each other to function. Ordinarily if an object needs another object to run, I like to pass it in the constructor. But I can't do that in this case, because one object has to be instantiated before the other, and so therefore the second object does not exist to be passed to the first obj...
I want to override access to one variable in a class, but return all others normally. How do I accomplish this with __getattribute__?
I tried the following (which should also illustrate what I'm trying to do) but I get a recursion error:
class D(object):
def __init__(self):
self.test=20
self.test2=21
def __geta...
Hi,
I am working with PHP and I am wondering how bad practise it is to combine lots of funtions into a class. I am aware of it's not the purpose of classes, but the reason why I would do this is to provide a namespace. How big impact does it make to initiate let's say 10 classes at the execution of a PHP script isntead of let's say 2 or...
I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP c...
I notice that get/set is not the c++ way as far as I can tell by looking at boost/stl, and even reading the writings of some of the top c++ experts.
Does anyone use get/set in their c++ class design, and can someone suggest a rule of thumb on where if at all this paradigm belongs in the c++ world?
It is obviously very popular in Java, ...
An example of what I'm talking about:
class Person < ActiveRecord::Base
def name=(name)
super(name.capitalize)
end
def name
super().downcase # not sure why you'd do this; this is just an example
end
end
This seems to work, but I was just read the section on overriding attribute methods in the ActiveRecord::Base docs (...
In C++, I can't think of a case in which I would like to inherit private/protected from a
base class:
class Base;
class Derived1 : private Base;
class Derived2 : protected Base;
Is it really useful?
...
Hi Stackers
I have a class named Page with a private property currently called _pageData which stores all the information (such as title, content, keywords etc).
However, this to me doesn't look so good when I refer to it $this->_pageData. I want to think of a better name, and I'd imagine there would probably be a standard or 'best pr...
I'm not really sure how to title this question but basically I have an interface like this:
public interface IFoo
{
string ToCMD();
}
a couple of absract classes which implement IFoo like:
public abstract class Foo : IFoo
{
public abstract string ToCMD();
}
public abstract class Bar : IFoo
{
public abstract string ToCMD()...
I recently took my Db initiating code out of the __construct of my Page class and placed it just after I initiate the Page class. I removed it from within the Page class because I want to be able to access it from anywhere (other classes for example). It also takes server, username, password and database arguments to it when initiated, a...
Has anyone out there actually used inversion of control containers within compiler implementations yet? I know that by design, compilers need to be very fast, but I've always been curious about how IoC/DI could affect the construction of a programming language--hot-swappable syntaxes, anyone?
...
I'm writing some data analysis software and decided to use such approach:
epn:
model/data.py <- Model definition
model/reader.py <- How to read data into model
view/gui.py <- main gui frame (wx)
view/dialogs.py <- different dialogs (wx)
epn.py <- controller
For communication between gui and data I used wx.lib.pubsub. So when button 'Mo...
I have the following code sample :
public class Base
{
public virtual void MyMethod(int param)
{
Console.WriteLine("Base:MyMethod - Int {0}", param);
}
}
public class Derived1 : Base
{
public override void MyMethod(int param)
{
Console.WriteLine("Derived1:MyMethod - Int {0}", param);
}
public...
I know that having diamond inheritance is considered bad practice. However, I have 2 cases in which I feel that diamond inheritance could fit very nicely. I want to ask, would you recommend me to use diamond inheritance in these cases, or is there another design that could be better.
Case 1: I want to create classes that represent diffe...
Whenever I try to write graphical programs (whether a game or really any GUI app) I always wind up with one or two god classes with way too many methods (and long methods, too), and each class having far too many responsibilities. I have graphics being done at the same time as calculations and logic, and I feel like this is a really bad ...
After watching: The Clean Code Talks -- Inheritance, Polymorphism, & Testing
I checked my code and noticed a few switch statements can be refactored into polymorphism, but I also noticed I only used switch statements with enums. Does this mean enums are "evil" in OO-design and should be eliminated with polymorphism?
...
Hello, some time ago I found an article (Roles: Composable Units of Object Behavior) describing the pros of using Roles versus Interfaces or other ways of dealing with behavior requirements. Does any of you knows where I can find more literature about that, or knows more about Roles?
I know that that's almost a research topic, but maybe...
Closed as exact duplicate of this question. But reopened, as the other Singleton questions are for general use and not use for DB access
I was thinking of making an internal data access class a Singleton but couldn't convince myself on the choice mainly because the class has no state except for local variables in its methods.
What is ...
I teach a one semester University course in systems analysis and design. Topics include design patterns, UML, OOP, software development lifecycles, and the history, benefits and drawbacks of various methodologies (such as Agile/SCRUM/BDUF/Waterfall.)
Students who enter the course should have some exposure to programming, but in reality ...