oop

Is it considered bad practice to use a widgets title attribute to refer to it?

Would it be considered bad practice to use a widgets title attribute to refer it? For example I have a number of custom radioBoxCtrls on a panel I only ever need to get/set all the values at once so the container class(a panel) for the radioBoxCtrls objects has the following methods get_options() set_options() To set options for...

What is your favorite method to conceptualize a project?

I'm running into the issue with a new project that is it starting to get difficult to contain the whole thing in my mind and move it around. While I still do this for the majority of programming, I know that physical means can help significantly. What methods do you use? The 3 ideas I can think of are: Using Styrofoam balls to show c...

"Journaling" or "transactions" design pattern?

I'm looking to implement an object that is journaled, or has a persistent transaction in it. That is, the object contains data (a Map perhaps). As changes are made to the data, those changes are held separately, sandboxed if you will, so that any outside object can either reference the base state (before the changes) or can access the la...

Which pattern to use in replacement of composite with limited number of element type ?

Hi, I have an object can be compose by components but each components has a type and should be unique : Class Client{ Set<IComposite> elements } interface IComposite{ String getType(); } class Status implements IComposite{ String getType(){return "status"} } class ClientDates implements IComposite{ String getType(){return "c...

Nhibernate (and ORMs in General): work with Objects or ObjectIds?

This is something that has been pulling at me for a while. Consider a (MVC type) web application with an ORM (e.g. Nhiberate) as the data access layer. On one hand - the OOP/Rich domain model hand - I feel I should be passing around (references to) the real objects I am talking about. On the other hand - the DB/Web App hand - I feel ...

javascript inheritence

In javascript what sort of inheritence do you favour? The ECMA standard is to use prototpye chaining. So I just set the prototype of the object that's doing the inheriting (monkey) to invoke a new instance of the object I want to inherit from (animal): monkey.prototype = new animal(); I am aware there are other ways to achieve inherit...

difference between encapsulation and abstraction concepts

Hello everyone, Please can somebody explain to me the main differences between the principles of encapsulation and abstraction in objected-oriented programming (if possible with examples). Thanks in advance. ...

Problem with final field initialization in java: avoiding duplication of code using multiple constructors

I have a class with some private final fields: public class ClassA { private final Object field1; private final Object field2; ... } The class has several different constructors, with a variety of arguments: public ClassA(Object arg1, Object arg2); public ClassA(int arg1, String arg2, boolean arg3); These constructors calcula...

What is a good or best in your opinion way to do OOP in C# ASP.net

I have been working on coming up with the best wy to put the classes for the best OOP. Sometimes I wonder if I am trying to over kill the thought process. I am thinking now to have as an examples the Categories Object Files Cateogories.cs - Object File CateogoriesDAL.cs - Data Access Layer CateogoriesBLL.cs - Business Logic Layer C...

OOP Value Objects and Entities in the same class

I am refactoring an old procedural PHP website into a tasty OOP application with a light sprinkling of Domain Driven Design for added flavour. I keep stumbling upon cases where I have a need for classes that can have subclasses which are either entities or value objects. An url object, for example. There are a zillion urls out there an...

How to have my derived class only accept a specific derived type of another object

I have a couple different custom backup programs and I want to combine them into a single one. Doing so, I'm working on my OO design to help keep the driving program simple and easy to follow by abstracting my server and database information. I'm using two different hosts (Discount ASP.net and Rackspace). Both of them go about their bac...

Is encapsulating Strings as byte[] in order to save memory overkill ? (Java)

Was recently reviewing some Java Swing code and saw this: byte[] fooReference; String getFoo() { returns new String(fooReference); } void setFoo(String foo) { this.fooReference = foo.getBytes(); } The above can be useful to save on your memory foot print or so I'm told. Is this overkill is anyone else encapsulating their St...

What's the difference between closures and traditional classes?

What are the pros and cons of closures against classes, and viceversa? Edit: As user Faisal put it, both closures and classes can be used to "describe an entity that maintains and manipulates state", so closures provide a way to program in an object oriented way using functional languages. Like most programmers, I'm more familiar with ...

Simple Design problems

Hi, Tell me simple design flaw which you have faced(irrespective of programming language) while you code and how did you over come with that? ...

Suggest best way to use class methods and object methods in Objective-C?

Hi, I am using both methods in my project, can you please let me know, which one is best for in which situation? Regards, Sri ...

When is using __call__ a good idea?

What are peoples' opinions on using the __call__. I've only very rarely seen it used, but I think it's a very handy tool to use when you know that a class is going to be used for some default behaviour. ...

Is there anything that i can do in C but not in C++?

Possible Duplicate: Is there something that I can do in C but I cant do in C++ ? I am in a graduate level and I seen that C++ is derived from C with OOP added. I have a doubt that is there anything I can do in C but not in C++. ...

Getters and Setters in C++

Should I use getters and setters in C++ or is it better to access class data directly? ...

How to specify class dynamically in PHP?

So normal class methods and object creation goes like this... $obj = new Class(); $obj2 = Class::someMethod(); Can I instantiate "class" dynamically? How? I want to do something like... $class = "Class"; $obj = new $class?; $obj2 = $class?::someMethod(); ...

Convert a class to a subclass on instantiation

I'm writing a framework for querying the Mediawiki API. I have a Page class which represents articles on the wiki, and I've also got a Category class, which is-a Page with more specific methods (like being able to count the number of members in the category. I've also got a method Page#category? which determines if an instantiated Page o...