Hey all,
I am designing a program that will accept from input a series of tokens and feed them to a finite state machine which I have designed. I have designed a test finite state machine in object-oriented style, with structs for the machine itself and transitions, etc. but the application I am writing is one where speed is very importa...
Hi,
Recently I came up with the idea of simple pattern for dynamic creation of object. And I real love it.
I am sure that that "wheel" was invented and named. Could someone could point to some GOF pattern?
Problem: have huge number of objects that I don't want to have all initialized at the beginning. All are instances of one class.
I...
I've just read about the Single Responsibility Principle and at one point Robert C. Martin states that it is sometimes hard to see that a class has more than one responsibility.
Can anyone provide an example of such a class?
...
I have a plugin which registers a post type, taxonomy and handles some business logic.
I went ahead and made my perfectly working plugin OO based and now it only works some of the time.
Its set-up like the following:
class Fruit {
public function __construct() {
add_action('init', array(&$this, 'init'));
...
Hi.
Let's say I've got a class called House with the two fields
name
address
Each of these fields has got a getter and a setter.
Now I want another method in the House class called setValues. This method should set the fields with properties from a passed object of a different type.
There would be two ways on how to create this met...
Bear with me... I don't think this is too subjective but maybe I'm wrong.
Recently I wanted to factor out some repetitive code which drew a custom Bitmap background on our BlackBerry app.
(This question is not really about BlackBerry though, so I'll provide some details here about the BB GUI so that non-BB Java people can weigh in...)
...
PHP and .Net have closures; I have been wondering what are some examples of using closures in OOP and design patterns, and what advantages they have over pure OOP programming.
As a clarification, this is not a OOP vs. functional programming, but how to best use closures in a OOP design. How do closures fit in, say, factories or the obse...
Hi folks,
I need to know if I am going about something the right way.
For a given page, I am instantiating an object for the page itself. Let's call that object myPage. Within the page I have containers (usually div tags). When I go to an admin component to work with a specific div, I instantiate an object for that as well. Let's call ...
Example:
$this->getResponse()
->appendBody('Hello' . $name)
In the previous example, I understand the use of the first arrow operator, but not the second, since I don't know whether what the second one does is similar to passing arguments to the function, in which case I wonder why it doesn't go inside the parenthesis.
...
class Model_User extends ORM {
// columns: UserID, Name
// public $Name ; // this didn't work
}
Currently I create an object:
$user = new Model_User() ;
and access columns like:
$user->Name = 'My Name';
I'd like to have my IDE show me all the columns in the data model to avoid misspellings and to now right away what fields I ca...
I have a complex hierarchy of nested objects, with all of the child objects (stored an array of objects in the parent class) containing a property linking back to their parent: fairly simple and straightforward, with no real problems. If I do a var_dump of any object in the hierarchy, I'll get a recursive reference in the dump, exactly a...
If I`m programming a game in which there is a worker that cuts wood (from trees), where would I put the "cutWood" method, in the worker class, or the tree class?
EDIT:
The first example I read on OOD was about a circle (a class called circle) which has in it a method called "calculate area".
Now, sure enough a circle doesn't calculate i...
Using
Visual Studio 2010
.Net Framework 4
C#
Linq to Entities
Issue
I would like to be able to apply Object Oriented Principles like DRY and SOLID to some Linq Projections. With compiled queries or passed parameters I can apply these to the rest of Linq successfully so far, just not in the projections.
Please let me know if this i...
Can you please suggest a book for studying objected oriented approaches and programming.
...
Hi all.
I am using Propel, a PHP ORM.
I really like it.
I love to be able to write this code:
$offer->setTitle('20% off everything')->save();
But what about if I want to create a increaseImpressions method?.
Would you use it like this:
$offer->increaseImpressions()
or like this:
$offer->increaseImpressions()->save()
?
...
I am currently implementing something similar to an hospital intra site, where doctors can see info about their patients.
Currently, I have a LOT of info regarding each Client: his full name, date of birth, blood type, where he lives, diseases he had, etc.
My first attempt was something of the form:
class Client {
private string f...
Hello, guys, I am programming a GUI for an application, a cd container to insert cd, and currently I am not very clear and I think I need some help to clarify my understanding about object oriented design.
so, first, I use observer pattern to build abstract Model and View classes and also the concrete models(cd container) and concrete ...
As far as programming with the object-orientated paradigm go, which is the better, easier-to-use language, C++ or C#? What are the distinct differences. Oh, and is C# a strict-superset of C or not.
As a side note, are there any other worthwhile paradigms worth looking at other the OO? (That can be used with C++/C#).
...
If I use array_walk inside a class function to call another function of the same class
class user
{
public function getUserFields($userIdsArray,$fieldsArray)
{
if((isNonEmptyArray($userIdsArray)) && (isNonEmptyArray($fieldsArray)))
{
array_walk($fieldsArray, 'test_print');
}
}
private function test_...
1st Question:
In PHP there is:
$b = new SomeClass();
$a = "foo";
$b->$a("something"); // This is the same as $b->foo("something");
How do you do this in C#?
2nd Question:
In PHP I can iterate through each method on a class, similar to:
$a = new SomeClass(); // Which implements methodA, methodB;
foreach($method in get_class_metho...