oop

Object Identity Maps and webapps

In a recent discussion on ORMs for webapps someone mentioned that there are times you don't want to have IdentityMaps for webapps. I don't understand this, because it seems as though in the context of a singular request to the app, you would want all work on records to be consistent. This means if I "look" at an object A which references...

OOP - Modelling Client and Employees class with Person as a base.

Apologies if this was already asked but, I have had a look and can't find anything. I am trying to work out the best way to model the following in C#. I have sketched out a few idea but none of them feel right. I have created an abstract 'Person' class. My application will have Clients and Employees. Obviously, A Client is a Person An ...

Good problem domain for introduction to OO project?

I'm working with someone who's looking to get back into programming after several years of IT support work. They know all the iterative programming basics and have used them frequently, but their only object-oriented programming experience was in college. The goal is to come up with a decent-sized project that is good for illustrating ...

Design classes - OOPS features

Hi Friends, Actually I am interested in improving my designing capability(designing of classes with its properties, methods etc) when a problem is given. ie How to decide what could be the classes involved? and then decide the methods and properties? Can you guys suggest me good material for improving on this. Regards, Justin Samuel. ...

Where can I find object-oriented Perl tutorials?

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I'm reading these now, but what else is out there? Note: I've made this community wiki to attempt to produce something better than Google, which appears to have mediocre tutorials that are more about o...

What should I consider when choosing between chainability and language constructs?

I have tough time making this design decision. I could go with traditional new language construct to initialize objects, and use them through variables, such as: $o = new Object('arg'); $o->method(); $o->property = 'value'; $o->save(); Or I can choose factory pattern and aggressive chainability like as Object::new('arg')->method()->...

Passing another class amongst instances

Hi! I was wondering what is the best practice re. passing (another class) amongst two instances of the same class (lets call this 'Primary'). So, essentially in the constructor for the first, i can initialize the outside instance (lets call this 'Shared') - and then set it to a particular value whilst im processing this class in main()...

Object-Oriented Perl constructor syntax

I'm a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I don't get what this line does at all, but I always see it. Do I need it? my $type = shift; #I'm turning the array of inputs into a has...

Can someone explain javascript prototypal inheritance

Hi all, I wonder if someone could be kind enough to explain the function.prototype thingie (thingie!!??) in OO javascript. I come from a server side programming background, and may be I am not grasping the whole concept of prototypes, Given the following snippets of code: var animate=function(){}; animate.angular=function(){/*does som...

Where does the idea that an object should only do one thing come from?

I'm not sure I agree with it, so I'd like to find the book or journal article behind this idea so that I can check that I understand exactly what they're saying and what context they mean it. I think I understand the idea - I just want to know the source so I can check where the idea comes from. why I'm asking: The term "do one thing"...

How to eliminate duplicate code

I have the following methods, that all return different types. I have four of such methods. In the spirit of good programming practices(DRY), should be using some OOP techniques such as inheritance or interfaces here or just roll with it. Any comments or code examples are welcome. Thank you. static AttendeeResponse GetAttendees(Http...

For C/C++, When is it beneficial not to use Object Oriented Programming?

I find myself always trying to fit everything into the OOP methodology, when I'm coding in C/C++. But I realize that I don't always have to force everything into this mold. What are some pros/cons for using the OOP methodology versus not? I'm more interested in the pros/cons of NOT using OOP (for example, are there optimization benefits ...

Is there any library for T-SQL to turn it object oriented?

Hi all, Microsoft Ajax Library has added full object orientation to JavaScript. Is there any library, framework, component, package, etc equivalent for T-SQL? It would be very nice to write object oriented SQL scripts in MS SQL Server. Cheers, afsharm ...

Object Oriented module/definition for networking devices/topology ?

Is there any module/definition available for a class/schema for representing the topology, connection, access details etc of networking devices ? The intent is to use this for automation, and to manage routers/servers as objects rather than as tcl keyed lists/arrays which gets unwieldy. ...

learning php OOP

Hi Guys, I'm learning PHP and I'm not that familiar with OOP yet - I've read a book about it, but never really programmed using OOP. I would also like to learn how to use a framework (codeIgniter, as it seems the most 'friendly' to beginners). Now I need a suggestion from you: would you recommend learning FIRST the 'standalone' OOP a...

Am I using a global state here, is there any better way to do this?

I am modifying some legacy code. I have an Object which has a method, lets say doSomething(). This method throws an exception when a particular assertion fails. But due to new requirement, on certain scenarios it is okay to not throw the exception and proceed with the method. Now I am not calling this method directly from the place whe...

Submitting FutureTasks to an Executor - why does it work ?

I have the following test code. import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.FutureTask; class MyTask extends FutureTask<String>{ @Override protected void done() { System.out.println("Done"); } public MyTask(Runnable runnable) { super(runnabl...

Best practices / info: Writing a PHP4 ORM

For a number of reasons (all of which can, basically, be broken down to bad management decisions) we're unable to switch to PHP5, meaning we'll have to support PHP4 for probably a few more years. Since a lot of our applications (as with a lot of web apps) are glorified CRUD apps, and because I like to pick up the occasional home project...

Is the .NET Stream class poorly designed?

I've spent quite a bit of time getting familiar with the .NET Stream classes. Usually I learn a lot by studying the class design of professional, commercial-grade frameworks, but I have to say that something doesn't quite smell right here. System.IO.Stream is an abstract class representing a sequence of bytes. It has 10 abstract method/...

Having trouble getting a return value from a Javascript callback

Hey everyone - I'm having some difficulties properly getting a return value from one of my Javascript callback functions, and it looks to be dependent on a race condition, but I'm not sure: JSOBJ.container = function() { return { getName: function() { var value; companyfn.app.getInfo(callback); function callback(foo) ...