oop

How are distributed services better than distributed objects?

I am not interested in the technology e.g. CORBA vs Web Services, I am interested in principles. When we are doing OOP, why should we have something so procedural at higher level? Is not it the same as with OOP and relational databases? Often services are supported through code generation, apart from boilerplate, I think it is because we...

Enums and inheritance

I will use (again) the following class hierarchy: Event and all the following classes inherit from Event: SportEventType1 SportEventType2 SportEventType3 SportEventType4 I have originally designed the Event class like this: public abstract class Event { public abstract EventType EventType { get; } public DateTime Time { ge...

Overload and hide methods in Java

Hi, i have an abstract class BaseClass with a public insert() method: public abstract class BaseClass { public void insert(Object object) { // Do something } } which is extended by many other classes. For some of those classes, however, the insert() method must have additional parameters, so that they instead of overriding it I...

Why do Java/C# edge out C++ as the recommended language to learn OOP on SO?

I noticed after reading the answers/discussion to this question (What is the best language to learn OOP on?) - that more and more people are recommending C# or Java over C++ to learn OOP on. A simple term search on that answer page results in 10 hits for C++, 21 for C# and 27 for Java. Now, I understand that these 2 languages fix a lot ...

Designing a class in such a way that it doesn't become a "God object"

I'm designing an application that will allow me to draw some functions on a graphic. Each function will be drawn from a set of points that I will pass to this graphic class. There are different kinds of points, all inheriting from a MyPoint class. For some kind of points it will be just printing them on the screen as they are, others ca...

Ruby Abstract Class Design

I'm creating a video game. It has Characters & Items. Since I want Characters & Items to each have a name, should I make another class called NamedObjects with just a name field and have Characters & Items extend that? Or is that going overboard? ...

Good suggestions for learning OOP PHP

I've been trying to learn PHP OOP and have looked at multiple articles, but have yet to find a good resource for learning. I want to learn from the user of setters and getters, $this->, constructors, and so on...! Can anyone please suggest me something? I noticed MOST teachings leave out the explanation of $this->. I want to learn magic ...

Simple form validation. Object-oriented.

Problem statement: It is necessary for me to write a code, whether which before form sending will check all necessary fields are filled. If not all fields are filled, it is necessary to allocate with their red colour and not to send the form. Now the code exists in such kind: function formsubmit(formName, reqFieldArr){ var c...

Passing arguments between classes - use public properties or pass a properties class as argument?

So let's assume I have a class named ABC that will have a list of Point objects. I need to make some drawing logic with them. Each one of those Point objects will have a Draw() method that will be called by the ABC class. The Draw() method code will need info from ABC class. I can only see two ways to make them have this info: Havi...

How to return Current Object in a Static function in PHP

I neet access to current object in a static method. Code: protected static $name; public static function name($modulename) { self::$name = $modulename; } public function __call($name, $arguments) { $me = new test(self::$name); return $me->$name($arguments); } I want to be able to call method log in Log class. Like this...

Javascript Instance Variable Syntax (AJAX page refresh)

I'm having difficulty with Javascript instance variables. I'm trying to make an easy way to refresh the chat page, looking for new messages. The AJAX call supplies a mid, or the lowest message id to be returned. This allows the call to only ask for the most recent messages, instead of all of them. MessageRefresher.prototype._latest_mid;...

Java extends classes - Share the extended class fields within the super class.

EDITED: Straight to the point... I have a class public class P_Gen{ protected String s; protected Object oP_Gen; protected Object oP_Gen2; public P_Gen(String str){ s = str; oP_Gen = new MyClass(this); oP_Gen2 = new MyClass2(this); } } Extended class: public class P extends P_Gen{ ...

modelling database entities in MVC -- how to create them?

I'm working on a PHP web app and I'm trying to use the MVC model. I have a lot of things that exist as 'database entities' -- a row, or a set of related rows, that are conceptually one human recognizable 'thing'. So I often try to provide an interface to that thing in a model class. So of course, the run of the mill functionality is t...

Transferring objects between two independed applications (C#)

Hi, is it possible to transfer a object from one application to another (in C#)? I'm working with a CAD API. The initialization of that API takes a few seconds (10 - 15). Would be nice if I could initialize the object only once in App1 and call it up from App2 whenever I need it. Any ideas? Thanks! ...

CakePHP form $options['options']

Hey! Total CakePHP noob here. Updated at bottom \/ This is sort of a two fold question. In a view that is used for adding user objects I would like to use a drop down (selection) field in the form. Each user belongs to a group so when I add a user I want a drop down that contains all of the groups that the user could possibly join. ...

C#: Inheritance, Overriding, and Hiding

I'm having difficulty with an architectural decision for my C# XNA game. The basic entity in the world, such as a tree, zombie, or the player, is represented as a GameObject. Each GameObject is composed of at least a GameObjectController, GameObjectModel, and GameObjectView. These three are enough for simple entities, like inanimate t...

Naming convention for non-virtual and abstract methods

I frequently find myself creating classes which use this form (A): abstract class Animal { public void Walk() { // TODO: do something before walking // custom logic implemented by each subclass WalkInternal(); // TODO: do something after walking } protected abstract void WalkInternal(); } class Dog : Animal { ...

Why can i not rewrite parent class?

I want to rewrite core/adminthtml/block/widget/tabs.php class which is a super class for core/adminhtml/block/sales/order/view/tabs.php class. Here is config code for both scenarios: <blocks> <adminhtml> <rewrite> <sales_order_view_tabs>Jimmy_SalesAffil_Block_Widget_Tabs</sales_order_view_tabs> <widget_ta...

Add additional content to the middle of string from within a method

I am working with a log file and I have a method which is creating a generic entry in to the log. The generic log entry looks like this: public StringBuilder GetLogMessage(LogEventType logType, object message) { StringBuilder logEntry = new StringBuilder(); logEntry.AppendFormat("DATE={0} ", DateTime.Now.ToString("dd-MM...

Accessing the Private Constructor

I am java developer, went for an interview. I have been asked a question about the Private constructor 1) Can I access a Private Constructor of a Class and Instantiate the class. I was thinking and gave the answer directly--- "NO" But its wrong, can any one help Why NO? and How we can achieve this ...