I know downcasting like this won't work. I need a method that WILL work. Here's my problem: I've got several different derived classes all from a base class. My first try was to make an array of base class. The program has to select (more or less at random) different derived classes. I had tried casting from a base class to the derived c...
Within my a certain function of a class, I need to use setInterval to break up the execution of the code. However, within the setInterval function, "this" no longer refers to the class "myObject." How can I access the variable "name" from within the setInterval function?
function myObject() {
this.name = "the name";
}
myObject.pr...
For my example, I have a Person class with an arbitrary number of associated Addresses associated with it. So there will be an Addresses collection as a member of the Person class.
In many applications which use the Person class, we will just want to retrieve the "Default" Address object. There are a few design questions regarding the...
I'm at a point in my development learning where I feel like I must learn more about interfaces.
I frequently read about them but it just seems like I cannot grasp them.
I've read examples like: Animal base class, with IAnimal interface for things like 'Walk', 'Run', 'GetLegs', etc - but I've never been working on something and felt lik...
Hi Everyone,
I have to write a multiplayer pacman game in Java for a university assignment and I'm after some feedback for my design so far.
So I'm trying to go down an MVC style and this is what I've sketched out.
I've never designed anything using MVC, so my knowledge is really only from the pragmatic programmer and a short lecture ...
The following code in javascript gives me the error "this.callback is not a function
function ajaxRequest()
{
var httpObject;
this.open = open;
this.callback = function(){};
function getHTTPObject()
{
if (window.ActiveXObject)
return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRe...
Have read through the MSDN naming guidelines and could not find a clear answer, other than that you should try to avoid underscores in general. Let's say I have the following:
public class Employee
{
private string m_name; //to store property value called Name
public string Name
{
get { return m_name; }
set...
I'm learning Java (and OOP) and although it might irrelevant for where I'm at right now, I was wondering if SO could share some common pitfalls or good design practices.
...
Does anyone have any good resources for refining my skills in developing class diagrams? Would like any strong tutorials in UML 2.0 ideally, but searches seem to be returning poor results.
Also currently revising for a final year exam and really want to try and get my teeth into a practice paper with a model answer, I've searched high a...
I'm currently modifying a class that has 9 different constructors. Now overall I believe this class is very poorly designed... so I'm wondering if it is poor design for a class to have so many constructors.
A problem has arisen because I recently added two constructors to this class in an attempt to refactor and redesign a class (SomeMa...
C++ newbie question. Please, verify I'm doing it right.
I have a global application class spawning it's little kids and I need to give the kids access to some of the application facilities. So I decided to pass them to children by reference.
I tested the idea as show below. It seems to work fine. I just wanted to make sure I'm not doin...
I have to write an ASP.NET application that connects to our legacy IBM Universe Database and we are using a product called mv.net which allows us to connect, read, write, select, run server side programs, etc.
I want as little code repetition as possible but I also want as little data transfer as possible as well.
In order to open ...
If I've got Foo with a property of type Bar. Both are persisted in a database which can be retrieved by an ID. (The IDs are actually used in the line of business by customer service claims. So they're not just index placeholders.) I could take the approach shown with b1 or b2.
Chaining entities together scares me since if you push t...
I want to create a class file dynamically. Here it goes...
With the given ResultSet, extracting the metadata I want to build a class file dynamically with getter and setter methods for all the columns that exist in ResultSet. Also I should be able to use this class file generated where ever I want in my later use.
Can any body suggest me...
I recently read an interesting comment on an OOP related question in which one user objected to creating a "Manager" class:
Please remove the word manager
from your vocabulary when talking
about class names. The name of the
class should be descriptive of its'
purpose. Manager is just another word
for dumping ground. Any
...
When designing a new object model I always start with the class diagram function in visual studio. Once I have drafted the first version, with a couple of tweaks based on gathering new info or a change in requirements I start working on the actual implementation.
As development gets busy and targets have to be met the diagram goes by t...
Although class friendship is one of the last resorts of C++, does this pattern make sense?
class Peer
{
public:
friend class Peer;
void GetSecret(const Peer& other)
{
const std::string& secret = other.GiveSecret();
std::cout << secret << std::endl;
}
private:
const std::string& GiveSecret() const
{
...
Is there a tool which will take a set of c++ headers and output UML class diagrams?
...
Is there a good rule of thumb or test I can perform to determine whether a method or field belongs in a class? How can identify when a member does not belong?
I find that my single biggest stumbling block in object-oriented design is trying to figure out what goes where. It seems like there are far too many cases where the answer is: ...
I want a simple class that implements a fixed-size circular buffer. It should be efficient, easy on the eyes, generically typed.
EDIT: It need not be MT-capable, for now. I can always add a lock later, it won't be high-concurrency in any case.
Methods should be: .Add and I guess .List, where I retrieve all the entries. On second thou...