oop

New to start with Design Patterns

Possible Duplicates: which resources would you recommend for learning object oriented programming (C#)? Learning/Implementing Design Patterns (For Newbies) Hello everyone, I was working in Information Technology for few years. I was planning to learn designing / design patterns and wes really confused where to start and how t...

PHP class instantiation. To use or not to use the parenthesis?

Hey. I've always assumed that - in the absence of constructor parameters - the parenthesis (curly brackets) follow the class name when creating a class instance, were optional, and that you could include or exclude them at your own personal whim. That these two statements were equal: $foo = new bar; $foo = new bar(); Am I right? Or ...

Are there good tutorials on OOP with PHP?

I'm not new to OOP, but new to PHP. I know Java, Objective-C and some other object oriented languages. So I'm looking for a comprehensive overview of how OOP looks like in PHP. ...

Doubt on using polymorphism in coding an expression parse tree/evaluator

I am working on an interpreter for a toy language, just to learn about building an interpreter. I have already implemented a simple parser for the grammar that generates a parse tree. Now, the usual way of evaluating the parse tree would be to use polymorphism on the nodes of the parse tree, with code that looks something like below (in ...

Should I inherit or subscribe to events?

If I create a Abstract BaseForm for my Windows application, I can use it to do common things when the application's forms are loaded. I can also override the OnLoad method, or I subscribe to the Load event (BaseForm_Load). Which approach is better from the design and performance point of view? ...

Where's the difference between self and $this-> in a PHP class or PHP method?

Where's the difference between self and $this-> in a PHP class or PHP method? Example: I've seen this code recently. public static function getInstance() { if (!self::$instance) { self::$instance = new PDO("mysql:host='localhost';dbname='animals'", 'username', 'password');; self::$instance-> setAttribute(PDO::ATT...

OO / DTO Architecture question

We have an entity (class) containing data and methods (lets call it Person). There are other classes that need to use the data in this object (let's call one of them Accountant), but do not need to use the functionality in it's methods. Would it be better to send the entire Person object to Accountant, or to create a new PersonData o...

Java vs. OO Design

I'm working on an inherited system which has some design issues which "OO Buzzwords" frown upon, and some I personally dislike. It's a stock and sales handling program for a comic book store. I have an Article class, which can be any item (Magic cards, toys), and a Publication class that inherits from Article, which represents books an...

Modelling a shared entity puzzle

Have the following entities in my domain: Project Task User Context A user can have multiple projects, tasks and contexts. A project can have tasks and contexts and a task can have contexts. I am a little unsure as how best to model Contexts as it will belong to multiple entities i.e. a user can add a list of contexts, these context...

Translator Pattern

In a previous job, my manager suggested use of a Translator pattern for converting data from a DataTable to objects. Basically, the Translator class had only static (i.e. class) methods so it was an aggregation of function calls. My initial approach was to implement constructors for each object that could take a DataTable row as an argum...

abstract-class in java

Is possible to create objects of an abstract class in Java ...

Using constant fields vs initial data

Hi, I'm designing some new class diagrams for extending an existing office automation application. In a special case I have an option to use extra fields on Entity1 to determine something or use additional data rows in Entity2 to determine that. I believe first approach is better because it does not force us to insert initial data while...

Abstract class design

Is this an acceptable design ?? Abstract class public abstract class SomethingBase { public abstract int Method1(int number1); public abstract int Method2(int number2); } public class Class1 : SomethingBase { public override int Method1(int number1) { //implementation } //i dont want this method in this cla...

Is Form validation and Business validation too much?

I've got this question about form validation and business validation. I see a lot of frameworks that use some sort of form validation library. You submit some values and the library validates the values from the form. If not ok it will show some errors on you screen. If all goes to plan the values will be set into domain objects. Here th...

Basic C# property question

In C# do properties need to reference private member variables, or can I just declare the properties and use them directly in the class code? If the former is the best practice, then does that rule out using C# property short-hand? I.e. public string FirstName { get; set; } ...

please help me with the my OOP PHP doubt?

I have the foll prog class Person { var $name; function Person () { } } $fred = new Person; $fred->name = "Fred"; $barney =& new Person; $barney->name = "Barney"; echo $barney->name; echo $fred->name; both the echo statements give the right same output ie "Fred" and "Barney" so whats the use of giving & while declaring $barne...

Silverlight DependencyProperty problems

Here's the situation: I have a custom TextBox control that contains multiple other TextBox controls. I need to turn IsTabStop off in the parent control, but I still want to expose a new IsTabStop property, which the sub-textboxes are template-bound to. I wrote the following code: using System.Windows.Controls; public class CustomTextBo...

Merging two objects

Quotes object: Array ( [0] => Array ( [sitecaptions] => Array ( [id] => 2 [caption] => Great camera deals! [linkurl] => http://www.99hotdeals.com/cat/Cameras and Camcorders ) ) ) The Posts Object: Array ( [0] ...

Doing MVC or not doing it?

I'm new to MVC structure and feel it's harder to get things done because it's a new way of doing things. Are there anybody who has experience of MVC vs. pages way of doing things. Is the MVC way of doing it the holy graal now or is there still value doing ordinary object-oriented development (or even procedural pages webdev)? Is MVC a fa...

How can i make these functions use variables for the id? I cant the setTimeout to work when I do.

<script type="text/javascript"> function changeBarAWidth(){ var bar = document.getElementById('firstbar'); bar.style.width = lengthA+"px"; } function increaseBarA(){ if(lengthA < fullBarA){ changeBarAWidth(); lengthA = (lengthA + 2); setTimeout("increaseBa...