oop

How to instantiate a certain number of objects determined at runtime?

So here's my problem... Let's say I have a simple "Person" class just with "FirstName" and "LastName" attributes. I want to have a form where the user says how many "Persons" he wants to create and then he fills the name for each one. E.g. user wants to create 20 persons... he puts 20 on a box clicks the button and starts writing nam...

ASIHTTPRequest code design

I'm using ASIHTTPRequest to communicate with the server asynchronously. It works great, but I'm doing requests in different controllers and now duplicated methods are in all those controllers. What is the best way to abstract that code (requests) in a single class, so I can easily re-use the code, so I can keep the controllers more simpl...

Separate threads for socket input and output

I got assigned to work on some performance and random crashing issues of a multi-threaded java server. Even though threads and thread-safety are not really new topics for me, I found out designing a new multi-threaded application is probably half as difficult as trying to tweak some legacy code. I skimmed through some well known books in...

In Perl, how do I put multiple packages in a single .pm file?

I'm pretty sure that I read somewhere that it's possible, but there are a few gotchas that you need to be aware of. Unfortunately, I can't find the tutorial or page that described what you need to do. I looked through the Perl tutorials, and didn't find the one that I remember reading. Could someone point me to a page or document that de...

Rapid switch to Java for an experienced C++ developer

I'm am looking for online tutorials/books, which assume a solid knowledge of OOP/Design patterns concepts and stress on differences (both conceptional and syntactical) between C++ and Java thus allowing for a rapid development in the latter. Thank you very much in advance, appreciate your time. ...

When should we create a new method?

I'm trying to find out if there is a consensus on when we should create a new method in our code. For example should we only create a new method/function if we are going to be using the code again (therefore we obviously cut down on the lines used) or is it common to do it just to avoid code clutter as well. I've been programming for a l...

are scenarios/stories the new interface in BDD/TDD?

PHP is somewhat crippled since it doesn't have return types (yet). I need my code to throw an exception when X already exists. I can write this in a scenario, but I'm not able to go from the scenarios to the interface my class should implement. Actually this problem is the same in TDD I guess. There seems more that I can tell through my...

Uncle Bob style OOP in VB.NET: how to learn?

I’ve been professionally writing VB.NET software for seven years. However, I don’t have a strong computer science background – four courses while studying education at university in the 90s that gave me some CS basics and exposure to Pascal, C and Lisp. Anyway, there are a whole bunch of practices that I’m missing – testing, patterns, ...

Access of Non-Static Function of a Class in PHP

Why is this legal in PHP? <?php class Foo { public function test() { echo "hello\n"; } } Foo::test(); ?> test() is a non-static function but I can access it without an instance. ...

What design pattern should I use for import/export?

I have a calendar event object. I have plans to make it compatible with CalDAV/iCal/vCal protocols/file formats, which require the event be serialized and de-serialized to and from different formats. I could write an ImportICal, ExportICal, ImportVCal, ExportVCal, etc. set of methods, but that doesn't seem like a very good approach, bec...

Object reference

I have a situation programming for the iPhone. I have an Object (object A) that contains another Object (object B). Is there a way to reference object A from Object B? If so, how would I do it? ...

How to design/plan for web application development?

I'm interested in learning how to design/plan for web application development, in a multiple developer team scenario. Assuming the role of "Project Manager/Lead": What "documents" are needed for successful web application development? What UML diagrams are needed and to what degree? In the design/plan phase does each - as per use ...

php singleton per object with distinct identifier

This is something I was thinking about the other day. I want to have a singleton-like object. Instead of a single instance of a class, I want to have a single object with a matching variable. For instance. an existing employee object has a employee_id = 100 the getEmployee static method is called with employee_id = 100, i want to ret...

Architecture of very complex php applications ?

I want to know which php architecture strategies developers use in complex php applications . So far , i know the mvc structure which consists of models, views and controller (and controller plugins which handle with common tasks such as user access controller ). I know some good php frameworks which makes some common stuffs easier .But...

Object representation of betting rounds at poker

Hi, I'm writing a HandConverter of a poker hand. This is my first project and I'm trying to do it right from the beginning. I got already the most parts, like lists of players, their position, stack sizes, cards for different boards, what game is being played and so on, but I struggle with the representation of the betting, especially t...

Help with my first own object in JavaScript/jQuery

I have written a PHP script that checks whether a domain is available for registration or not. To automate the process, I have also written a js script that automatically sends AJAX calls to the PHP script and tells the user whether the domain is available or not, without submitting the form: $(document).ready(function() { functio...

practical uses of OOP

I recently had a debate with a colleague who is not a fan of OOP. What took my attention was what he said: "What's the point of doing my coding in objects? if it's reuse then I can just create a library and call whatever functions I need for whatever task is at hand. Do I need these concepts of polymorphism, inheritance, interfaces, pat...

Advice needed from PHP/Cake PHP expert

I'm very new to programming (besides SQL and databases), but I ultimately want to master Cake PHP for web development. Now, given how new I am, I'm rather lost as to how I get started. Down the road, I want to use MVC framework so that I help myself be disciplined in the way I build. However, I know basic knowledge of PHP and OOP PH...

accessing private variable from member function in PHP

I have derived a class from Exception, basically like so: class MyException extends Exception { private $_type; public function type() { return $this->_type; //line 74 } public function __toString() { include "sometemplate.php"; return ""; } } Then, I derived from MyException like so: cl...

C#: Calling a virtual method from constructor; advice?

In out program, we have the following class hierarchy: public class PagePanelBase: UserControl public sealed class CameraParameters: PagePanelBase CameraParameters overrides the BackColor property, setting the background color of some of the components it contains. If BackColor is set from the PagePanelBase constructor (InitializeComp...