oop

calling a method of current class from a method of another class

Hi, I am working on a class A which has a method -(void)DoSmthing1. I am making a call to another method-(void)DoSmthing2 in class B. Now after doing some operations in class B, the method is supposed to call back a method-(void)DoSmthing3 previous class. How will i call a method of current class from another class?? Can someone pleas...

How to model this classes/database tables?

Hello. I have to model classes and database tables for a "User" entity. This "User" entity have this properties: User Name Age Gender Email But I have 2 user's type: "Paid users" and "Free users". Each one have his own properties: Paid User Fee Rate Free User Expiration Date Level "Paid User" and "Free User" ar...

Customizing the Rendering of a Zend_Form_Element_Radio

I have an object that's an instance of a Zend_Form_Element_Radio. I'd like to customize how these radio buttons are displayed. The manual remarks Radio elements allow you to specify several options, of which you need a single value returned. Zend_Form_Element_Radio extends the base Zend_Form_Element_Multi class, allowing you to spe...

Which is the most elegant Design for this simple OOAD problem?

I am trying to get started with OOAD, this problem came to my mind and I am not sure I can find a good solution: (it is a supersimplfied version of a real world case). A fisherman fishes at a pond with a fishing rod. At every launch of the fishing line there is a likelihood of catching a fish equals to 1/10 when there is sunlight and 1/...

Statistical accumulator in Python

An statistical accumulator allows one to perform incremental calculations. For instance, for computing the arithmetic mean of a stream of numbers given at arbitrary times one could make an object which keeps track of the current number of items given, n and their sum, sum. When one requests the mean, the object simply returns sum/n. An ...

Inheritance and static properties

I don't understand the following phenomenon, could someone explain me please what I got wrong? public class BaseClass { public BaseClass() { BaseClass.Instance = this; } public static BaseClass Instance { get; private set; } } public class SubClassA : BaseClass { public SubClassA() ...

what does $this mean within a class definition?

As I continue to try and improve myself as a junior PHP developer, I have started to try break down other peoples work. I find it helps me understand, as well as giving me ideas. Two things I do not get, in a PHP class, what $this means, and what array($this,'some_function') means when I would expect a function name in it's place. Many...

Why is the java.util.Scanner class declared 'final' ?

I use the Scanner class for reading multiple similar files. I would like to extend it to make sure they all use the same delimiter and I can also add methods like skipUntilYouFind(String thisHere) that all valid for them all. I can make a utility-class that contain them, or embed the Scanner Class as a variable inside another class but ...

Object oriented programming in C

Possible Duplicate: Can you write object oriented code in C? Hi, can someone point me to a tutorial explain me how OOP concepts can be implemented in ANSI C: virtual functions inheritance best practice A book about OOP programming ANSI C would be great too. ...

Conflict between providing (optional) functionality and encapsulation?

I need to provide a certain operation on the elements of my class Foo. This operation is specific and weird enough that I don't really want to make it a member function. On the other hand, it works on the internals of the class, which I don't want to expose. Here is the class: class Foo { typedef std::map<int,double> VecElem; std::...

Keeping modules independent, while still using each other

A big part of my C++ application uses classes to describe the data model, e.g. something like ClassType (which actually emulates reflection in plain C++). I want to add a new module to my application and it needs to make use of these ClassType's, but I prefer not to introduce dependencies from my new module on ClassType. So far I have ...

How to model this classes withN Hibernate and Fluent.NHibernate Maps?

Hi. I'm using ASP.NET MVC with NHibernate and Fluent.NHibernate Maps. I would like to know how to map the classes on Fluent and to create the database tables on my MySQL: public class AgenteDeViagem { public virtual int Id { get; set; } public virtual string Email { get; set; } public virtual AgentePessoa AgentePessoa { ge...

Can you help me fix the exception/error message handling in my control architecture script?

Can you help me fix the exception/error message handling in my control architecture script? First, let me post the actual script... Note: some of the code's indentation is a bit off, but I am uncertain how to fix it. I apologize. class FrontController extends ActionController { //Declaring variable(s) private static $instance; pro...

PHP Class Logic

My question is rather simple, given: class MyClass{ function a(){ echo "F.A "; } function b(){ echo "F.B "; } } $c=new MyClass; $c->a()->b()->b()->a(); So that it will output: F.A F.B F.B F.A What changes to code need to be made for this to work, or should it work as is or even just what this is called...

A question on APIs

Recently I have learnt of the many benefits (including beautiful looking code) of OOP. So, now I am trying to write a small physics API for my personal use, perhaps to be put in a few little games. This is mainly because I like to practice coding, and I like my physics. But the thing is, many APIs have an interface like this (including...

A entity with active record, is a object or a component?

A entity with active record is a object or a component? ...

How does this control architecture script look?

I am looking for feedback on my control architecture script (included below). Specifically, I am looking for feedback regarding the script's design, organization, commenting, and formatting. I enjoy php programming as a hobby, and am looking to learn where I can improve my code. Thanks in advance! class FrontController extends Acti...

Should I use C#-like property handling in PHP?

Hey SO community, I saw here: http://www.mustap.com/phpzone_post_203_setter-and-getter an argument for using a type of property handling common to C#, that is: If in C#, you can define a class like this: public class Person { private string _name; public string Name { get{ return _name; } set{ _name = value...

How to define difference between business model and a data model?

I see the term often used as if there is a concrete distinction between the two when discussing MVC for OO languages. From what I get from context it is that business models perform an action to mutate the data models. Is that a correct way to express the difference. I guess what confuses me though is that most examples of models mix bo...

destroying a singleton object

What is the best way to destroy a singleton object? case A: Single threaded Environment case B: Multi Threaded Environment Sample snippets(if any) will be really helpful. [EDIT] I don't have a specific use case I am just trying to understand that IF AT ALL the singleton has to be used how to destroy it correctly. As i understand...