I have a class hierarchy:
class ParentClass:
def do_something(self):
pass # child classes have their own implementation of this
class ChildClass1(ParentClass):
def do_something(self):
<implementation here>
class ChildClass2(ParentClass):
def do_something(self, argument_x):
<implementation here>
...
Hi
Here is my class that implements copy constructor
public class TestCopyConst
{
public int i=0;
public TestCopyConst(TestCopyConst tcc)
{
this.i=tcc.i;
}
}
i tried to create a instance for the above class in my main method
TestCopyConst testCopyConst = new TestCopyConst(?);
I am not sure what i should pass...
I am writing an ASP.NET application which I have a UI layer, business logic layer, and data access layer. From my data layer I return business objects to the business logic layer and pass these on to the UI layer. However, I'm not sure what to do when I want to perform a save/insert with data from the UI layer.
Should I create the bus...
Hello,
This is theory question but any advice is more than welcome..
When designing OO applications according to many books you should have a class for every table of the database with the fields as class variables..
But when you want to get data for multiple tables and store it in an collection of objects you find out that you need a...
I have this class in a UTF-8 encoded file called EnUTF8.Class.php:
class EnUTF8 {
public function ñññ() {
return 'ñññ()';
}
}
and in another UTF-8 encoded file:
require_once('EnUTF8.Class.php');
require_once('OneBuggy.Class.php');
$utf8 = new EnUTF8();
//$buggy = new OneBuggy();
echo (method_exists($utf8, 'ñññ'))...
This is a design problem I face regularly and I'd like to find some general insights about the subject. The code provided here is just an example.
In the design phase it's easy to decide you need an object:
User
==========
Unique ID
Login name
Password
Full name
And it's easy to convert it into a database object:
CREATE TABLE user (...
I often have the same trouble when I have to design my class for a web application. The requirements are :
- maintainable (no copy-paste for instance)
- layers fully separated (the business layer doesn't have to know which method of the data layer is used)
- high performance : don't load useless data.
First I have a table with all my cu...
I am not sure if what I want to do breaks Object oriented guidelines or not so I will explain what I am doing and hopefully you guys can show me a better way if I am wrong. I tried asking this question before but I gave a poor example so I think it just caused more confusion.
So I have a main class, USBCommunicator. The constructor take...
Unfortunately I cannot provide any code examples, however I will try and create an example.
My question is about Objects and memory allocation in PHP.
If I have an object, lets say:
$object = new Class();
Then I do something like
$object2 = $object;
What is this actualy doing? I know there is a clone function, but thats not what I...
I am new to PHP and programming in general. I have been working on a few things with PHP that have required me to create classes, which has been fine, except that I can't seem to get my class methods to work on arrays that are properties of the class. I must be doing something pretty fundamentally wrong, because it doesn't seem to work r...
I recently read that making a class singleton makes it impossible to mock the objects of the class, which makes it difficult to test its clients. I could not immediately understand the underlying reason. Can someone please explain what makes it impossible to mock a singleton class? Also, are there any more problems associated with making...
I'm looking to fire an event each time a property within my class is SET. I'd like to be able to trigger this same event whenever one of my properties are set. I have (around 12 of them)
I.e.
public class MyClass
{
private int _myHeight;
private int _myWidth;
public int myHeight
{
get { return myHeight; }
set { myHei...
I have a relatively complicated data structure to model. I would like to do this with a record structure in Delphi, and the structure is complicated enough to justify splitting this into nested records. A simplified example:
type
TVertAngle = record
strict private
fDecDegrees: Double;
fDegrees: integer...
Hey all, I'm learning Doctrine + Symfony and I may have chosen too complex a data model for my own good.
Here's an overview:
Users create Gizmos.
There are 5 Modules to choose from. Users cannot define new ones, only instantiate them.
A Gizmo has any number of Instances in any order. An Instance has one Module ID.
Instances are config...
In set theory, a set is a superset if it contains everything in the original set and possibly more. A subset however is does not contain everything of the initial set.
With that in mind, in most object-oriented programming languages (I'm thinking Objective-C but I know the same is true for Java and others), the parent class is called th...
I am wondering if it is possible for an object in javascript to delete itself once it has finished its task.
For example, I have the following object...
var myObject = Object.create(baseObject);
myObject.init = function() {
/* do some stuff... */
delete this;
}
myObject.init();
Does this work? If n...
I am learning Haskell after years of OOP.
I am writing a dumb web spider with few functions and state.
I am not sure how to do it right in FP world.
In OOP world this spider could be designed like this (by usage):
Browser b = new Browser()
b.goto(“http://www.google.com/”)
String firstLink = b.getLinks()[0]
b.goto(firstLink)
print(b....
I would like to have a pulldown menu close itself upon a mouseleave event, after a short delay. But I'm having trouble getting it working.
Consider the following methods in an object: (I am using jQuery)
myObj = {};
myObj.message = "woot!";
myObj.bindEvents = function() {
var that = this;
$("#menuPanel")
...
I want to be able to do something like this:
$table_object->getRows()->where($wer)->or($or)->orderBy('field', 'DESC');
If i were sure that all the methods will be called each time and in that order, then it would be simple and i can return an instance of the object itself on each method call so that the query gets build and finally ex...
For example lets say I have a set of classes and methods to do so:
$obj->method1()->method2();
Is there anyway for method1() to know with in itself that its the first method being called or for method2 to know that its the last?
Some more details
I just want to be able to build a set of these calls so that it either returns an instan...