oop

php the point for __get() and __set() magic

PHP 5 introduces the magic method __get() and __set(). From my understanding it is a shortcut for having to write each member's getter and setter; <?php class Person { private $firstname; private $lastname; function __set($var, $name) { $this->$var = $name; } function __get($var) { return $this->$...

Placing Business Rules inside a Repository

I have a table that is storing a list of rules. In my code, I need to retrieve those rules and maintain the list of rules (via. the Repository Pattern) so that I can reuse them. I then need to generate(business logic) a list of objects based on the rules for a particular period of time, eg, a list of holiday objects filtered by the rul...

What causes MOVE_CAST_ERROR when down-casting a reference object in ABAP?

I'm creating a class that inherits from a parent class with protected instantiation. The super class has a static method that provides an instance of the class. The following code causes a run-time error MOVE_CAST_ERROR: data: o_child type ref to zchild. o_child ?= zparent=>provide_instance( ). I have also tried: data: o_parent typ...

Why was TDataSource created originally?

What was (or would be) the reasoning behind creating TDataSource as an intermediary between data bound components and the actual underlying TDataSets, rather than having the components just connect directly to the TDataSets themselves? This may seem like kind of a stupid question, but I am working on a broad set of "data viewer" compon...

Is behaviour driven development about design or analysis?

The more I read about BDD and how it is supposed to be improved TDD the more confusing it all seems to me. I've found quotes from expert that say it's about design, but also from other experts that say it's about analysis. The way I currently see it is this: 1) analysis: BDD from wikipedia The result of object-oriented analysis ...

Android, Get a DecorView child

Hi, I wonder if it is possible to get a decorViews child. For example if I have a decorView object and I know that the child of the decorView is a FrameLayout, is there someway for me to get the FrameLayout object just by using its parent? Obviously I could use getViewById() in the traditional way, but if I only want to use the parent...

Name of a class that wraps an external process?

What would you call a class that wraps some external process Worker (starts and stops it, reads stdin, stdout, etc.)? WorkerFacade? WorkerGateway? WorkerWrapper? ...

If only one object field is required in a method, what should be passed as a parameter - an object or a field value?

Lets say there is a method that searches for book authors by book id. What should be passed as a parameter to such method - only book.id (int) or whole book object? Or another example. In java I need to do some work with current url of the page. What should be passed to such method - only request.getRequestURL() or whole request? I kin...

Which design patterns to use to implement this business logic?

Hello all, I am trying to determine the best design pattern to use for a business key validation web service. The basic logic flow is coded below. The program will take a parameter and use a field to help determine the path to take in searching multiple systems where this business key can be found. System1 is searched first, if not f...

This is OOP or like OOP

Hi, For long time reading and testing, but i want know. This is correct PHP OOP code, or not Class User { function Add($Name, $Password){ $sql_str = "INSERT INTO User SET Name = '$Name', Password = '$Password'"; $sql->do_sql($sql_str); } function Del($UserID) { $sql_str = "DELETE FROM User WHERE UserID = '$UserID'";...

Reference or tutorial to clarify object reference confusion

Working with my ongoing TFrames-based component set project, I'm coming across various instances where I am wanting to replace one of the TFrame's components (usually non-visual) at runtime with one that is generated dynamically at runtime. I think I've probably found the answer to my immediate problem here, but in my own digging arou...

What is significance of static keyword in Java and in C++ ?

What is the importance of Static keyword in Java and in C++ and how it's functionality differ in both programming languages ? ...

Java: When to make methods static v. instance

I have a Gene class that keeps track of genes. Gene has a method for calculating the distance between two genes. Are there any reasons to make it static? Which is better? public static int geneDistance(Gene g0, Gene g1) or public int geneDistance(Gene other) Arguments for/against making it static? I understand what it means for a me...

Is there a way to call an object's base class method that's overriden? (C++)

I know some languages allow this. Is it possible in C++? ...

When writing a Perl module, do I have to specifically check for an object instance in all my methods?

I'm writing a module that has several methods. Let's consider this : package MyPackage; sub new { ... } sub do_your_job { ... } 1; What is to stop someone calling do_your_job like MyPackage->do_your_job instead of $obj->do_your_job ? Do I need to check in every method that I'm receiving a reference as the first argument? ...

What's the benefit of calling new on an object instance?

I'm reading Programming Perl, and I found this code snippet: sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = { color => "bay", legs => 4, owner => undef, @_, # Override previous attributes }; return bless $self, $class; } With...

How to generate automatic properties (get, set) for Visual Studio 2008 C++

Having read this thread: http://stackoverflow.com/questions/3017/how-to-generate-getters-and-setters-in-visual-studio and tried (somewhat) the techniques described, I have failed miserably to graduate beyond the longhand way of writing Getters and Setters. While I recognize the conceptual advantage of encapsulation (private members o...

Examples of Object-Oriented Projects Help Procedural Programmers

Please help me identify some small to medium sized open source projects that embody object oriented design (preferably in C++ or Java). I would like to use these projects to demonstrate how real world problems (as opposed to contrived text book examples) can be solved with an object oriented design. I want to be able to present a plaus...

How to design a system that queues requests & processes them in batches ?

I have at my disposal a REST service that accepts a JSON array of image urls, and will return scaled thumbnails. Problem I want to batch up image URLs sent by concurrent clients before calling the REST service. Obviously if I receive 1 image, I should wait a moment in case other images trickle in. I've settled on a batch of 5 images. ...

Can I use array_filter() on a class array?

I'm attempting to intercept and filter items out of a class set array, $this->_vars, in a stripped down version of Smarty (not my choice :| ) Here's what I've been attempting to use: Class callback function private function callback_check($var){ if(!in_array($var['link_id'], $this->returned_array['items'])) return false; else return...