oop

object-private Vs class-private

Is there a notion of object-private in any OOP language ?? I mean more restrictive than the classic private access ? Private (or class-private) restricts the access to the class itself. Only methods that are part of the same class can access private members. object-private : restricts the access to the object itself. Only methods objec...

Coding to interfaces?

I want to solidify my understanding of the "coding to interface" concept. As I understand it, one creates interfaces to delineate expected functionality, and then implements these "contracts" in concrete classes. To use the interface one can simply call the methods on an instance of the concrete class. The obvious benefit is knowing of ...

java web applicaton layout, please explain some design principles/patterns

I'm looking at this java web application that is using hibernate, jsp's, and spring framework. (from what I can tell!) the file layout is like this: classes/com/example/project1 inside project1 /dao _entity_Dao.java /dao/hibernate/ _entity_DaoHibernate.java /factory DaoFactory.java DaoFactoryImpl.java /managers ...

Built-in method for finding a specific instance of an object in PHP?

I really am clueless when it comes to object-oriented programmings, so forgive me if this is obvious... I am using a Zend extension which returns a request as a nested object. I need property a based on if the object has property b. Right now I am using a foreach loop with a conditional to search for property b and, if I get a match, se...

Data Mapper: Is my interpretation correct?

I'm trying to confirm now, what I believe about the Data Mapper pattern. So here we go: Section A: A Data Mapper is a class which is used to create, update and delete objects of another Class. Example: A class called Cat, and a Data Mapper called CatDataMapper. And a database table called cats. But it could also be an xml file called ca...

Data Mapper and Relationships: Implementation strategies?

I've almost finished my Data Mapper, but now I'm at the point where it comes to relationships. I will try to illustrate my ideas here. I wasn't able to find good articles / informations on this topic, so maybe I'm re-inventing the wheel (for sure I am, I could just use a big framework - but I want to learn by doing it). 1:1 Relationshi...

PHP OOP dilemma: how to keep a database connection 'within' a class object?

And here i am again! ;) Im developing (well, im still in planning phase) a web-app where i would give to other developer the possibility to write theyr own plugins/modules (in the way of CMS does, drupal, joomla, etc). My problem is that i have to force the developers to use the methods i wrote for interact with databases, for many rea...

Events or abstract methods, best practices

A subclass needs to know when particular events occur withing its superclass, but there are more than one ways for the superclass to break the news. Here are 2: dispatch an event call an abstract method which the subclass could eventually override I was wondering if best practices would recommend one of the approaches over the other....

Books of OOP programming for Non-OOP programmers?

Hi Guys, I'm trying to build my own learn path to understand OOP for web development mostly with MVC Frameworks under PHP. My big problem is that I'm a COBOL programmer and it not seems to hard for me understand web technologies such as PHP, my worst enemy is OOP programming .. Comming from an Structured Language such as COBOL it's is h...

Object-oriented programming & transactions

A little intro: Class contains fields and methods (let me skip properties this time). Fields represent a state of the class. Methods describe behavior of the class. In a well-designed class, a method won't change the class's state if it throws an exception, right? (In other words, whatever happens, class's state shouldn't be corrupted)...

Determining a PHP object's name.

In Java (well, Android's version at least) all objects have a getClass() method which returns the object's class and you can then call getSimpleName() to get the human-readable name of the object. This is great for logging. I'd like to be able to do something similar in a PHP program I've been working on. Is there any way to find out wha...

Does Object Oriented Design have a place in web development?

I work at a web development shop so naturally we deal with user profiles. When dealing with one of our sites I noticed that there was no 'User' class, which struck me as odd since we certainly have users. Instead the site relies on interacting with DataRows (this is C#) returned through static methods with little to no instantiation. ...

PHP method chaining benefits?

Still on the PHP-OOP training wheels, this question may belong on failblog.org. =) What are the benefits of method chaining in PHP? I'm not sure if this is important, but I'll be calling my method statically. e.g. $foo = Bar::get('sysop')->set('admin')->render(); From what I've read, any method which returns $this is allowed to be c...

OOP Game Design Theory

I've tried to develop a 2D game with C++ in the past using mere objects, however, in the design process I don't know how and what parts of the engine I should split into smaller objects, what exactly they should do and how to make them interact with each other properly. I'm looking for books, tutorials, papers, anything that explains the...

where to put entity related methods ?

Asp.net-mvc, using nhibernate. my vs.net layout is like: /dao (1 class per entity for database work, using repository) /model /mappings /factory (db factory that provides access to each entities Dao) Now I need utility methods, not sure where to put them. example: CartItems.cs CartIemsDao.cs Now say I have a method like: ILi...

Should a Finder Method be part of the Data Mapper, or part of the domain class?

In Martin Fowler's Patterns for Enterprise Application Architectures book (page 229 in German, Lazy Load) he gives an example with this code: public List getProducts() { if (products == null) products = Product.findForSupplier(getID()); return products; } like you can see, the finder method seems to be part of the domain class...

Can I use reflection and a string to get/set the correct property of an object?

Hi All, I am using c# & .NET 3.5. A vendor gives us an object that has properties of UserVarNbr1, UserVarData1, UserVarNbr2, UserVarData2,... UserVarNbrN, UserVarDataN. Not the way I would have coded it but nonetheless, this is what we have to work with. Another object in the application returns a collection of items used to represent th...

Performance advantages of using methods inside of classes verses data structures with libraries of functions?

Basically is the only advantage of object oriented languages the improved understanding of a programs purpose? Do the compilers of object oriented languages break apart the objects into structures and function libraries? ...

How could I refactor this code with performance in mind?

I have a method where performance is really important (I know premature optimization is the root of all evil. I know I should and I did profile my code. In this application every tenth of a second I save is a big win.) This method uses different heuristics to generate and return elements. The heuristics are used sequentially: the first h...

When I have an abstract class, can I let another abstract class extend that one?

Let's say I have an abstract class called ViewController, and another abstract class called FormViewController. When someone wants to create a form, he must subclass FormViewController and implement its abstract classes. ViewController defines an abstract method loadView() and viewDidLoad(). FormViewController implements loadView() but ...