oop

Can you get a method name from within a method in PHP?

Is it possible to do something like this? public function something() { $thisMethodName = method_get_name(); // I made that function up, but is there some way of doing what it describes? } Thanks ...

Can a class return an object of itself

Can a class return an object of itself. In my example I have a class called "Change" which represents a change to the system, and I am wondering if it is in anyway against design principles to return an object of type Change or an ArrayList which is populated with all the recent Change objects. ...

Is this way of using Dictionary<enum,object> correct in this Production Planning example?

Consider a production planning application with many products. Each product has a list of InventoryControl objects keyed on InventoryControlType. Depending on the algorithm we run for production planning, we need to access to different types of InventoryControl objects for a given product. This works OK. However, today I needed to introd...

Java Class with string and a specified length

Hi All, I'm creating a java program that creates a file and fills it with data in string form with each field in the record limited to a specific length. What I think I need to do is to create a class that has a string for the data field and a length specifying the length of the string. And then somehow restrict it so that the string n...

How do you go from idea to implementation when designing classes for other developers in other locations?

I'm looking for inspiration on how to design classes from scratch in a project with multiple developers in different locations (so no whiteboard sessions.) Let's say you're tasked with implementing a rather big feature that is going to be used by the other developers later in the project. This feature will require several classes and wi...

iterator_to_array

DatePeriod is a PHP class for handling recurring dates. It has a very limited number of methods. So when I want to do basic array functions with the recurring dates, I have to copy it to an array with iterator_to_array. Strangely, copying it seems to clobber it. Any ideas why? $p=new DatePeriod(date_create('2008-01-01'), ...

How to create a Setter/Getter of UserControl in VB6?

For an unknown reason, VB6 doesn't interact the same way with UserControl than other object. I have a class that require to hold a graphical interface, a user control and need to be set to be later used from the get method. I have try many thing like using the special class VBControlExtender but without any success. Here is what I have...

Managing object instances

I want to be able to create and unknown number of objects. I'm not sure if there is a better way to manage and reference them. Lets use a standard OOP example... say every time a user enters a name for a pet in a text field and clicks a button a new pet object is created via the petFactory function. function pet(name) { this.nam...

Structure of orders in restaurant

What would be the best way to structure orders for a restaurant (available languages are php and javascript)? Since there are multiple tables (the ones you keep things on...), I thought of using objects in javascript. But I am quite new to javascript and absolutely new to OOP, so I'm not sure whether this is the best solution, and whethe...

What's the most straightforward way to achieve a chainable JavaScript framework like jQuery?

I'd like to write a small JavaScript (framework) that can chain functions with all following functions being aware of the data of its predecessor. Basically, I'm not interested in the bloat (I realize it's small, for my even smaller project though it's bloat) that jQuery provides but would like to mimic some of its behavior -- primarily...

HtmlHelper<ChildType> not assignable to HtmlHelper<MotherType>

I have a view ViewUserControl<SearchViewData> where SearchViewData: CommonViewData In this view I thus have a reference to Html. This is of the type HtmlHelper<SearchViewData> I create a custom HtmlHelper class called CommonHtmlHelper where I want to this (note the HtmlHelper parameter's type): public static SelectList Translat...

Creating Object instance from Posted data - PHP

Hi All What is the best way of creating and populating an Object from values passed in from a form? If for example, i have a class Car with properties Colour, Model, Make, Year and a method Save, which will either insert or update the record. I then have a form that has fields for all these values and it is submitted. I want to create...

How to tweak Rhapsody's "Reverse Engineering" tool to morph certain attributes as separate classes?

I am importing legacy C++ code using Rhapsody. One class has many (several dozen) attributes I'd rather see imported as separate classes. I've tried different "options" settings with no results. Is there a way to do this, other than redo all by hand? ...

Speed of C# lists

Are C# lists fast? What are the good and bad sides of using lists to handle objects? Extensive use of lists will make software slower? What are the alternatives to lists in C#? How many objects is "too many objects" for lists? ...

Did I understand right how to build robust php backends with Zend Framework ?

Most of you should know that 'famous' article about "Writing Robust PHP Backends with Zend Framework" After an insteresting reading, i decided to give it a try, since i couldn't be able to find the gold solution to handle my datas. Then, i tried to write kind of a skeleton, to have a concrete example. But some points looks weird for m...

Design Pattern to Handle Grouping Similar Entities Together

Over the past few years I've been on projects where we've run into a similar problem in our object hierarchy that always seems to cause problems. I was curious if anyone here knew of a classical OOP (Java, C#, PHP5, etc) design pattern that could gracefully handle this situation. Say we have an existing system. This system has, among ...

What is the best way to store and search through class objects (in PHP)?

I've around 80 instances of this class called Items and would like to efficiently search the objects by their ID or NAME. <?php class Item { public $id; public $name; //methods } ?> I'm using PHP5. ...

Where virtual constructors are used ?

I read about virtual constructors are used for implementing some design patterns, but didn't understood any need of virtual constructors. So what are virtual constructors and why we really need them? ...

is this violating the SOLID principles ?

i have something like this in my project, the project it's kinda finished already (it's working) i just want know if it is ok with the SOLID principles static public class Tools { static public GetProduct(this id){...} static public GetProductCategory(this id){...} static public GetUser(this id){...} // I also have h...

How to override private variable in javascript?

// base function function Man(name) { // private property var lover = "simron"; // public property this.wife = "rocy"; // privileged method this.getLover = function(){return lover}; // public method Man.prototype.getWife = function(){return this.wife;}; } // child function function Indian(){ var lover = "jothika"; t...