oop

Transition to OO ABAP?

It appears that most of our SAP programmers are using the old version of ABAP, the one before object-oriented stuff. I also noticed that the language is much cleaner and more modern with OO (they apparently took the opportunity to get rid of deprecated things). As the system is not rolled out yet, the time to make any redesign is now r...

PHP: performance of static methods vs functions

In PHP, (unlike what i originally thought) there an overhead of calling static methods vs simple functions. On a very simple bench, this overhead is over 30% of the calling time (the method just returns the parameter): // bench static method $starttime = microtime(true); for ($i = 0; $i< 10*1000*1000; $i++) SomeClass::doTest($i); ech...

Help with a PHP class

I have a session class that basicly just sets and retrieves session variables, the reason I made it was so I could easily change it to use sessions or something like memcache to set the items and have them accessible on multiple pages without hitting the database I then have this user class which uses the session object to get session v...

Can I retrieve objects I have used before?

Is there any way I can persist objects in PHP? I am creating some objects in a script, but I have to create them everytime the script is run (losing their state unless I save it to DB). I know variables can be persisted with $_SESSION global, but should I save objects in it? If object persistance is not possible, what's the use of OOP ...

Adding a decorator to a class derived from NSManagedObject

I'd like to add additional behavior to a class derives from NSManagedObject and there are 4 distinct (for now) groups of behaviors. I don't need my decorator class to be persisted with CoreData -- it's purely for adding run-time behavior. However, if I try to apply the standard Decorator pattern, I can't call '[super init]', which make...

object oriented programming: looking for good tutorials

Hi all, I am tired of tutorials that just enumerate the concepts with examples. How about some tutorials that show the wrong way of doing and then the correct way of doing things? It would be great to learn things like interfaces, delegates, abstract classes, singleton ...etc that way. It would be great to read some clean code online ...

What's the difference between functors and "generics"

I'm looking at OCaml's functors. It looks to me pretty identical to the so called generic objects in C++/C#/Java. If you ignore Java's type erasion for now, and ignore the implementation details for C++ templates (I'm interested with the language feature), functors are quite indentical to generics. If I understand it correctly, functor g...

How to change an object's interface based on its state?

Given a fairly complex object with lots of state, is there a pattern for exposing different functionality depending on that state? For a concrete example, imagine a Printer object. Initially, the object's interface lets you query the printer's capabilities, change settings like paper orientation, and start a print job. Once you start ...

How to structure a bigger/complicated project?

Hello, I'm creating this (big?) project in high school where I'm programming the game Shithead (card game) (so that two people can play against eachother). I'll use mostly PHP, MySQL, JavaScript and Ajax. But I have never made a project like this before. I have only made like CMS-systems and so on. Do you guys have any tips on how I sh...

Is the concept of abstraction relevant to tables in MySQL? If so, how can I do it?

I want to store data on various engines in a MySQL database, which includes both piston and rotary engines. In OO languages, I can create and extend an Engine superclass to obtain PistonEngine and RotaryEngine subclasses. The PistonEngine subclass would contain properties such as CylinderNo, PistonBore and PistonStroke. The RotaryEn...

What is the most appropriate design for an object who's database key is made up of multiple columns?

Suppose I have a table in my database that is made up of the following columns, 3 of which uniquely identify the row: CREATE TABLE [dbo].[Lines] ( [Attr1] [nvarchar](10) NOT NULL, [Attr2] [nvarchar](10) NOT NULL, [Attr3] [nvarchar](10) NOT NULL, PRIMARY KEY (Attr1, Attr2, Attr3) ) Now, I have an object in my applicatio...

Code organization style for C?

I know some higher level languages, all web based (PHP, javascript, some python). I've finally decided to learn a lower level language, and I've decided to go with C. The problem is that all the languages I use are based heavily on OOP. Seeing as (based on the research I did) C doesn't have classes or inheritance. As a result, I ask y...

MVC Object Oriented Techniques - How to minimise queries and maintain flexibility?

Hello there I am using an objected oriented MVC framework in PHP (Kohana) and have kind of mashed together a few techniques to get stuff done. Problem is I am not sure how to keep things clean without calling lots and lots of queries per page. To illustrate my example, I'll imagine I am designing a stack overflow like site: I have ...

How to call the __del__ method?

I am reading a code. There is a class in which __del__ method is defined. I figured out that this method is used to destroy an instance of the class. However, I cannot find a place where this method is used. The main reason for that is that I do not know how this method is used, probably not like that: obj1.del(). So, my questions is how...

newbie to OO question

My question pertains to windows forms Let's say I have a combobox for customer and orders, and depending on the selection made on those comboboxes I populate a datagrid for all the Order details. I am interested in a double click event within the datagrid row. Upon the event 2 things can happen: the record was deleted. one or both ...

C#.net decorator pattern converting/setting collection...

Have a question about how to better optimize or speed things up. Currently my code seems to be running a bit slow... I have the following classes public class DataFoo : IFoo { } public class Foo { internal IFoo UnderlyingDataObject{get;set;} public Foo(IFoo f) { UnderlyingDataObject = f; } } Now, in ma...

Can I overload Perl's =? (And a problem while use Tie)

I choose to use tie and find this: package Galaxy::IO::INI; sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = {']' => []}; # ini section can never be ']' tie %{$self},'INIHash'; return bless $self, $class; } package INIHash; use Carp; require Tie::Hash; @INIHash::ISA = qw(Tie::StdH...

How can I design a perfect collaboration diagram for a distributed System?

I am a CS 3rd year Student, I'm working on a project for designing a Distributed stock management system that deals with the assembly of computers. I need help, I'm having problems with designing a collaboration diagram. ...

state design pattern from Java to Ruby

Hello, I have a working solution in java using a classic state design pattern and facing some difficulties translating it to ruby. I am new in ruby, but the diffuclty I believe lies in the differences on how patterns can be implemented in dynamic languages. My interface is describing the actions the model can execute in every state: p...

Where to put potentially re-useable helper functions?

This is language agnostic, but I'm working with Java currently. I have a class Odp that does stuff. It has two private helper methods, one of which determines the max value in an int[][], and the other returns the occurrences of a character in a String. These aren't directly related to the task at hand, and seem like they could be reus...