oop

Extending Enumeration Definition in a child class in .NET

I have a base class which needs to define an enumeration: BaseClass - SomeEnum I then need to create two derived classes from the base class and extend the values in the enumeration: ChildClass1 : BaseClass - SomeEnum - SomeEnumValue1 ChildClass2 : BaseClass - SomeEnum - SomeEnumValue2 In C# or VB.NET can someone provide th...

Checking if Class type is available in Javascript Namespace

I would like to check if a class type is even instantiable before attempting to instantiate it via the new keyword in javascript. For example var geocoder = new GClientGeocoder(); will fail if the GClientGeocoder class is not available in the namespace. What's the javascript idiomatic way to do this? ...

Class or Metaclass Design for Astrodynamics Engine

Gurus out there: The differential equations for modeling spacecraft motion can be described in terms of a collection of acceleration terms: d2r/dt2 = a0 + a1 + a2 + ... + an Normally a0 is the point mass acceleration due to a body (a0 = -mu * r/r^3); the "higher order" terms can be due to other planets, solar radiation pressure, thr...

Specify the supertype of a class upon instantiation/declaration?

Is it possible to specify the parent of a class when I instantiate/declare that class? For example, can I do something similar to this: MonitoredDevice<DeviceTypeToExtend> device = null; And then from that statement, the MonitoredDevice class would extend from the type parameter DeviceTypeToExtend. Now, I know that you can't use type ...

C# Is there any benefit to assigning class properties in the class constructor?

For instance, if I have a class like this: namespace Sample { public Class TestObject { private Object MyAwesomeObject = new MyAwesomeObject(); } } Is there any benefit to set it up so that the property is set in the constructor like this? namespace Sample { public Class TestObject { priva...

program not displaying simple side values for my triangle object properly in nslog

Project file here if you want to download: http://files.me.com/knyck2/918odc So I am working on the book "programming in Objective c 2.0" and working on exercise 8.5, where you have to build a bunch of classes and subclass a homemade abstract class into a square class a triangle class and a circle class. you also have to calculate the a...

Is there any OOP way to secure this MVC web app design?

I'm writing a shopping cart application for a family member's online seed business. It's a fairly straight-forward workflow - users select what they want to order, type in their contact information, and the application generates an HTML E-Mail receipt and sends it to the contact address. Now, here's the rub - I've implemented the appli...

C# - object-oriented way of writing HTML as a string?

Hi, I'm trying to programmatically send an email of all of the dll files and their versions in a directory, recursively. I'd like to send the email as HTML output, using a table. Is there a good object-oriented way of doing this? I'd hate to write all of the tags by hand. Something like: private string getHTMLString() { Directo...

I need an accurate, comprehensive and idiot-proof OOD tutorial to help me avoid Global variables in C#

Can anyone point me in the direction of a very good online OO Design (and Programming) tutorial or resource ? I appear to have badly designed a small AP in C# and now want to sort it out before I go any further and frustrate myself even more. I did try to do it quickly and only went over a small and insignificant (now I realise) tutori...

what is the differance between socket and serversocket?

If socket is representing client side and serversocket representing server side, why socket.read reads the data from serverside...Im really confused ...make me clear pls...? ...

CodeFile="Registration.aspx.cs" can add multiple partial classes files to this line in aspx page

I have created 3 partial classes and i want all of them to be grouped under same page. Like Registration -> Registration.aspx.cs, Registration_db.cs, Registration_validation.cs. Is it possible to group all these files under same category i.e registration under tree view of solution explorer. <%@ Page Language="C#" MasterPageFile="~/Ma...

How to enforce initialization of class variables without a constructor?

I have two classes: abstract Entity, abstract ClassA extends Entity, ClassB extends ClassA Entity is an generic class for all kinds of entities, such as Cars or Students. There is an static class variable called $_entity_name, which contains the exact class name of the entity in the ER diagram. The big problem: Entity can't set the va...

PHP Session Class and $_SESSION Array

Hello, i've implemented this custom PHP Session Class for storing sessions into a MySQL database: class Session { private $_session; public $maxTime; private $database; public function __construct(mysqli $database) { $this->database=$database; $this->maxTime['access'] = time(); $this->maxTime[...

How to avoid keeping objects marked as deleted ?

Scenario: The "Invoice" has a reference to the class "User". A user object is delete through the user himself or an administrator, but the invoice object still needs a recepient (the user). The user object could be marked as deleted instead of delete it physically. But I think it is a bad design to use an object, that is marked as delet...

Javascript Objects: Accessing object variables from methods

Hi all, Quick question, and one I am yet to work out on my own. I'll start with an example. object = { somevariable: true, someothervariable:31, somefunction: function(input){ if (somevariable === true){ return someothervariable+input; } } } object.somefunction(3); Obviously this won't wor...

Advise on object-oriented design.

Hi there. I would like some help with a OOD query. Say I have the following Customer class: public class Customer { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } It's a simple placeholder for customer related data. Next comes the CustomerFactory, which is used to...

Degree of relation between Java object and classes/interfaces?

Is there some way through the standard library or some already existing library to determine the degree of relation between two classes/interfaces in Java? Let's say I have an object and a list of classes/interfaces. Now I basically want to know the one class of that list, that has the shortest inheritance-tree path to this object. I ...

Double Buffering for Game objects, what's a nice clean generic C++ way?

This is in C++. So, I'm starting from scratch writing a game engine for fun and learning from the ground up. One of the ideas I want to implement is to have game object state (a struct) be double-buffered. For instance, I can have subsystems updating the new game object data while a render thread is rendering from the old data by guar...

Restructuring to not use Exceptions by Determining which Method is Implemented

So I'm developing something that works on dynamic variables using C# 4. And I'm in a situation where I have two variables a and b and I know that either a.Foo(b) or b.Foo(a) is defined. However I don't know which so at the moment I use something like this: dynamic a, b, result; ... try { result = a.Foo(b); } catch { result = b....

List all methods of a given class, excluding parent class's methods in PHP

I'm building a unit testing framework for PHP and I was curious if there is a way to get a list of an objects methods which excludes the parent class's methods. So given this: class Foo { public function doSomethingFooey() { echo 'HELLO THERE!'; } } class Bar extends Foo { public function goToTheBar() { ...