Assuming one has an abstract base class "foo" with __get() defined, and a child class "bar" which inherits from foo with a private variable $var, will the parent __get() be called when trying to access the private $var from outside the class?
...
I am working with Windows Forms Databinding, implementing interfaces like IDataErrorInfo. In order for this to work, the domain(or business) object is allowed to be in an invalid state. In fact, the domain object needs to retain the invalid value as the user entered it for IDataErrorInfo to work properly. As long as the object isn't p...
Is there any open source Object Database available? I would like to have a look at the source code and see how stuffs are implemented.
...
Hello! I am currently trying to create a menu system for a game and cannot arrive at any really sound way to do it. There are several menu screens, each of them non-trivial, so that I would like to keep these as separate classes. The main problem I am having is passing control between these menu screens.
I tried building each of the scr...
How would I go about creating a real world form creation class that I can use to display a new form with fields of different types, as how many fields I want, I can use drop downs and I can do all of this by using OOP?
...
Hello,
I want to parse an Apache access.log file with a python program in a certain way, and though I am completely new to object-oriented programming, I want to start doing it now.
I am going to create a class ApacheAccessLog, and the only thing I can imagine now, it will be doing is 'readline' method. Is it conventionally correct to i...
In OOP languages like C# or VB.NET, if I make the properties or functions in a super class protected I can't access then in my Form, They can only be access in my class that inherits from that super class.
To access those properties or functions I need to make them public which defeats encapsulation on re-write them in my class which de...
My teams evolution of TDD includes what appear to be departures from traditional oop.
Moving away from classes that are self sufficient
We still encapsulate data where appropriate. But in order to mock any helper classes, we usually create some way to externally set them via constructor or mutator.
We don't use private methods, ever.
...
This code is blunderous, as it adds a class to an array and later tries to pull it and manipulate it as if it were an object.
private function fail(event:Event):void
{
var myObj:MyClass;
var a:ArrayCollection = new ArrayCollection();
var x:MyClass;
var y:MyClass;
myObj = new MyClass;
a.addItem(myObj);
a.addItem(MyClass); // !!B...
Is there any real reason not to make a member function virtual in C++? Of course, there's always the performance argument, but that doesn't seem to stick in most situations since the overhead of virtual functions is fairly low.
On the other hand, I've been bitten a couple of times with forgetting to make a function virtual that should ...
One thing I struggle with is planning an application's architecture before writing any code.
I don't mean gathering requirements to narrow in on what the application needs to do, but rather effectively thinking about a good way to lay out the overall class, data and flow structures, and iterating those thoughts so that I have a credible...
During coding I frequently encounter this situation:
I have several objects (ConcreteType1, ConcreteType2, ...) with the same base type AbstractType, which has abstract methods save and load . Each object can (and has to) save some specific kind of data, by overriding the save method.
I have a list of AbstractType objects which contai...
I'm relatively new to .NET programming (and OOP in general) and I want to make sure I'm not developing bad beginner habits when designing my applications.
If you were hiring a new .NET developer and had to get him up to speed relatively quickly, but also wanted to make sure he adopts best practices (e.g., single responsibility principle...
In the early days of .Net, I believe there was an attribute you could decorate a class with to specify a default property.
According to some articles I've found, this appears to have been yanked from the framework at some point because it was a little confusing, and I can see how that is the case.
Still, is there another way to get th...
Method chaining is the only way i know to build fluent interfaces.
Here's an example in C#:
John = new JohnBuilder().AddSmartCode("c#").WithfluentInterface("Please").ButHow("Dunno");
Assert.IsNotNull(john);
[Test]
public void Should_Assign_Due_Date_With_7DayTermsVia_Invoice_Builder()
{
DateTime now = DateTime.Now;
...
This is probably a simple question. Suppose I have a object called Users and it contains a lot of protected variables.
Inside that Users class I have a method that creates a temporary Users object, does something with it, and if successful, transfers all the variables from the temp Users object into the one I have.
Is there some fa...
Should operations that could take some time be performed in a constructor or should the object be constructed and then initialised later.
For example when constructing an object that represents a directory structure should the population of the object and its children be done in the constructor. Clearly, a directory can contain director...
How would you call the constructor of the following class in these three situations: Global objects, arrays of objects, and objects contained in another class/struct?
The class with the constructor (used in all three examples):
class Foo {
public:
Foo(int a) { b = a; }
private:
int b;
};
And here are my attem...
What is and how can it be used in C#.
Can you use the same concept in Python/Perl?
...
I'm creating a (Java) class to represent an object in a musical score that has a specific onset time, and possibly a duration as well. I need a good name for this class. Is something like "Timed" or "TimedObject" appropriate? I've tried to come up with something that ends in "-able" (like Runnable) but I can't think of anything good; ...