I'm having a bit of a hard time articulating this problem. With different types, what considerations are there for how to organize methods that traverse the relationships to convert to a different type? While being forgiving about the precise modelli
EDITED Managed to get most of it working, but have a problem towards the end. I have an html file with a few input fields and div elements to which I have to append a recipe when it is created. So I have two classes separated in modules - recipe and
Very often I run into code that logic that should be within business object is repeated everywhere as such: if ( !string.IsNullOrEmpty( Employee.Name ) ) Display( Employee.Name ); where as it should be like this : if ( Employee.IsNameSpecified ) Disp
I've been doing MVC for several months now, and I store everything in my $registry object. When I create a new class, I only ever pass the registry usually, but I'm having to constantly pass the $this->registry when creating a new class. e.g. class s
I have a messageService class that I'm instantiating like this: require_once("./classes/messageService.class.php"); $messageService = new messageService(); THEN I want to use the $messageService object in my __autoload method which looks like th
In a class, I want to define an empty object and use it anywhere we need it. This object needs to be immutable to avoid accidentally modification. If this object is defined as a public static final member of the class, the object could be changed if
I'm running a code that throws an exception,I want run the exception code continuously whenever the exception is thrown it has go to starting and should start the program from starting. Here is my exception method and mainYou need to put the try / ca
I am trying to design an income return tax software. What is the best way to represent/store a form with hundreds of questions in a model? Just for this example, I need at least 6 models (T4, T4A(OAS), T4A(P), T1032, UCCB, T4E) which possibly contain
EDIT Ive rephrased the question so it better reflects what im trying to do I'm trying to create a suite of classes that all inherit from 1 "superclass" or "baseclass". However i'm looking for a way around having to implement the code f
I am working on a class which needs couple of helper methods. This methods are going to be used only by this class. So I am wondering which will be best practice i.e. whether declaring these helper methods as private methods or group them and put ins
In a test, I need to compare that 2 objects of a class have the same values for each of the class attributes. I do not need to compare 2 objects of the class outside of my testing. Is it better to implement the eq in my class (even though the product
I have this class: public class GameData { public int[,] mat { get; set; } public int dim { get; set; } public int goal { get; set; } public Game game { get; set; } public GameData() { game = new Game(); } } And this two other derived classes: public
This question already has an answer here: Return multiple values from a Java method: why no n-tuple objects? 6 answers While working with Java Applications, I feel most of the times one question : Why Java doesn't support multiple return values of me
I am trying to see the basics for what is required to call in a second class, because tutorials and the book I am using are over-complicating it by using user input right now. So here is what I tried. First is my main class and the second is the clas
Look at the following (pseudo) pattern: public abstract class Animal { public abstract AnimalType { get; } public abstract override string ToString() { return String.Format("{0}={1}", AnimalType, this.ToString()); ^ // does this even work? } } w
I have been doing web app for medical data collection for a long time. Clients always have this kind of request : adding a new field in the form, for example they want add "gender" in demographic form. Every time they request, I have to 1. Add a
This is a follow-up question to Is it possible to use object composition in PL/SQL? That question addressed how to create object types in PL/SQL which are mutually dependent (i.e. one attribute of each object is a reference to the other object). The
I ran into a peculiar issue I was curious about (and would like to find a workaround for). If I declare a variable NODES in my class: private static final String NODES = "nodes"; Everything works ok. However, if I declare the variable in an inte
Suppose I have a Serializable class ShapeHolder that owns an object that implements a Serializable Shape interface. I want to make sure the correct concrete shape object is saved (and the correct type is later restored). How can I accomplish this? in
I am new to programming so sorry i am not clear on things I created a class let say public class Users { public int ID { get; set; } } My first question is where should i put this class in term of the 3 layer design If i put it in the Business layer,
I have the following code to connect to MongoDB: try { $m = new Mongo('mongodb://'.$MONGO['servers'][$i]['mongo_host'].':'.$MONGO['servers'][$i]['mongo_port']); } catch (MongoConnectionException $e) { die('Failed to connect to MongoDB '.$e->getMessag
I am in the process of making a game, and in that process I have come across a bit of a problem. I have many different types of game elements. These are all of type Entity. There are many types of Entities, including ones that are visible and need to
Consider the following code: #include <iostream> #include <map> class Value { public: void set(const int intValue){ intValue_ = intValue; } int read() const { return intValue_; } void replaceIfInMap(){ std::map<int,int>::iterator it; it
This is a follow up question on the following answer : Parent Object in php class A { protected function doSomeStuff(){ echo 'a method that all children will need to call'; } } class B { protected $_parent; public function __construct($parent) { $thi
My question is a bit about programming techniques or, maybe, design patterns. Suppose several classes derived from base which contains a pure virtual method that should do some interactions beetwen them. For instance, Rectangle, Ellipse, Triangle and
This question already has an answer here: How to avoid ArrayIndexOutOfBoundsException or IndexOutOfBoundsException? [duplicate] 2 answers I'm making a simple Tic-Tac-Toe program but I'm getting java.lang.ArrayIndexOutOfBoundsException if my input goe
I've just started using OOP PHP and ran into a question. I've set up a generic mysql class that allows me to connect to a database and has some functions to obtain records from a table: class mysql{ //some lines to connect, followed by: public functi
I'm building a PHP calendar app for a photography group. They need to be able to assign multiple dates/times to a single event. As of now, I have an Events table and a Slots table (for time slots). Events only has id, title, and description, while Sl
Feel free to point me to other answers if these have already been asked! I'm just starting F# with the new release this month. I've got some background in both OO and functional languages (Haskell and Scheme, but not OCaml/ML). A couple of questions
Meaning, if I have: <mx:Tree> <!-- ... --> </mx:Tree> and I want to change some of the control's behaviour or add functionality, by doing (in AS): class ChristmasTree extends mx.controls.Tree { // ... } how do I change the MXML so that m