OOP, class/objects overkill.
What is a good gauge for knowing when a class is poorly designed or even necessary. In other words when to write a class and when no to. ...
What is a good gauge for knowing when a class is poorly designed or even necessary. In other words when to write a class and when no to. ...
I have 2 tables, for now as an example, ClientOrder and Products Table. Using Linq, I have been able to write all the queries that I want to run 1. Search by Client order 2. Search by Client name 3. Search by Product name 4. Search by Product ID I want to create methods for each of the above queries. The ? is, what pattern is appropriat...
Here's a Clone() implementation for my class: MyClass^ Clone(){ return gcnew MyClass(this->member1, this->member2); } Now I have about 10 classes derived from MyClass. The implementation is the same in each case. Owing to the fact that I need to call gcnew with the actual class name in each case, I am required to creat...
Do you have any idea, why the following code: public class A { public static int i = B.i + 1; } public class B { public static int i = A.i + 1; } Having: int aa = A.i; int bb = B.i; Says that aa = 2 (!!!) and bb = 1. I have a STACK OVERFLOW in my brain!!! As far as i understand, recursion stops on static ...
Let's say I have a class Foo implementing an interface such as MouseListener. The MouseListener interface consists of five methods but I only wish to override one of them (mouseClicked()). Is there a standard, idiomatic way of formatting the other methods? My inclination was to write the following: @Override public void mouseClicked(...
So I'm writing an application where one object has a bunch of delegate objects that it forwards messages to. The idea is that I can say someObject sendMessage:aMessage and aMessage will be sent to all of someObject's delegates (for any value of aMessage). The only way I've been able to do this is something like: sendMessage:aMessage ...
I would like to know whats faster. Help me out. I have a variable declared in a Method like so: public static Regex FindNumber() { return new Regex(@"\d+", RegexOptions.IgnoreCase | RegexOptions.Compiled); } As you can see it returns a Regular Expression. I also have another Method that looks like so: private static string...
I'm trying to create a set of classes where a common ancestor is responsible for all the logic involved in setting various properties, and the descendants just change the access of properties depending on whether they are required in the particular descendant. When I try to do it as shown below I get a compiler error: "cannot change acc...
Scenario I'm going to be as succinct as possible. Basically with reference to this classdiag, I have a facade which manages a list of SocketManager ( which manages one Socket connection). Each SocketManager logs in to a remote server using a unique SocketUserId. Furthermore, each SocketManager will accept messages from clients destined ...
This topic expands on When do/should I use __construct(), __get(), __set(), and __call() in PHP? which talks about the __construct __get and __set magic methods. As of PHP 5.3 there is a new Magic Method called __invoke. The __invoke method is called when a script tries to call an object as a function. Now on research I have done for ...
Someone asked What is a Wrapper? and it got me thinking - where would I point a new developer in search of some foundational description of useful patterns? The GoF book has long been a foundational part of the canon for OO programming, and all of us at one time or another have benefited from the descriptions of common patterns there. ...
So I'm not to OOP in PHP. Here is my issue I have a object that I can call a function from and it provides back an arrary. So here is the code. $obj = new OBJ(); function go($url){ $array = $obj->grabArray($url); echo $array['hits']; } go('http://www.mysite.com/hello'); This gives me the error Fatal error: Call to a member...
I need an inherited static function "call" to call another static function "inner" that has been overridden. I could do this with late static binding, but my host does not have php5.3 yet and so I need to work around it. class ClassA{ static function call() { return self::inner(); } static function inner(){ r...
I've heard people saying that good design involves using inheritance instead of littering your code with if block. In what situation should we use inheritance, and when condition block is just fine? ...
If you designed a toolkit, an application or a framework, mention the most reusable component you used of them, how portable it is, how many times you reused it, how many programmers worked on it with you, and how much time did it take you to ship it. and also the names of the patterns you applied while developing it. (approximately of ...
I'm looking for some good quality OO books, if any exist for VB .Net, that'd be awesome. Have you read anything that you would recommend? ...
There is a project written in PHP that is just simply all procedural ... step by step calling DB functions, processing, and printing out the output. And then it is changed to totally object oriented -- there is a singleton for the App object, and various functions are invoked through the App object. Someone claims that the memory usage...
I remember that at one point, it was said that Python is less object oriented than Ruby, since in Ruby, everything is an object. Has this changed for Python as well? Is the latest Python more object oriented than the previous version? ...
A very common pattern I see (I'm picking on Zend Framework, only because I was dealing with it at the moment of this question), is something like this: class My_Form extends Zend_Form { public function init() { $this->addElement(); } } Zend_Form is not an abstract class, but is perfectly usable on its own. This see...
There is a good generalized method for defining private and protected properties and methods in Javascript, here on the site. However, the current version of Prototype (1.6.0) doesn't have a built-in way to define them through its Class.create() syntax. I'm curious what the best practices are when developers want to define private and p...