Partially related to an earlier question of mine, I have a system in which I have to store complex data as a string. Instead of parsing these strings as all kinds of separate objects, I just created one class that contains all of those objects, and it has some parser logic that will encode all properties into strings, or decode a string ...
Hey there,
i bumped the other day into a little problem regarding C#'s properties.
Let's say i do have this setup:
public class Point
{
public float X;
public float Y;
}
public class Control
{
protected Point m_Position = new Point();
public Point Position
{
get { return m_Position; }
set
{
m_Position = value; }
...
I have two classes that work seperate from another, but they extend the same class. Is it possible to have them work the same instance of the extended class. I'm wanting the constructor of the extended class to run only once.
I know this isn't right but something like this:
<?php
$oApp = new app;
class a extends $oApp {}
class b extend...
I have a collection of heterogenous data that I pull from a database table mtable. Then, for every unique value uv in column A, I compute a function of (SELECT * FROM mtable WHERE A=uv). Then I do the same for column B, and column C. There are rather a lot of unique values, so I don't want to hit the db repeatedly - I would rather hav...
I have designed the following class that should work kind of like a method (usually the user will just run Execute()):
public abstract class ??? {
protected bool hasFailed = false;
protected bool hasRun = false;
public bool HasFailed { get { return hasFailed; } }
public bool HasRun { get { return hasRun; } }
privat...
If you have to retrieve data from a database and bring this dataset to the client, and then allow the user to manipulate the data in various ways before updating the database again, what is a good class design for this if the data tables will not have a 1:1 relationship with the class objects?
Here are some I came up with:
Just manipu...
I'm creating class library with some commonly used classes like persons, addresses etc. This library will be used in an multilingual application, and I am looking for the most convenient way to represent a persons gender.
Ideally I would like to be able to code like this:
Person person = new Person { Gender = Genders.Male,
...
I have a modeled a set of objects that correspond with some real world
concepts.
TradeDrug, GenericDrug, TradePackage, DrugForm
Underlying the simple object model I am trying to provide is a complex
medical terminology that uses numeric codes to represent relationships
and concepts, all accessible via a REST service - I am trying to
h...
I have a a polygon class which stores a list of Microsoft.Xna.Framework.Vector2 as the vertices of the polygon. Once the polygon is created, I'd like other classes to be able to read the position of the vertices, but not change them.
I am currently exposing the vertices through this field:
/// <summary>
/// Gets the vertices stored for...
Let's say I'm trying to implement a Chess Game.
I'd create my Chess classes in a Chess namespace. Now, should I prefix all my Chess related classes with the Chess word, or as they are already inside that namespace, should I just call them by what they are?
Example:
ChessGame vs Game
ChessPiece vs Piece
...
is there a way to define a value within a class in the __init__ part, send it to some variable outside of the class without calling another function within the class?
like
class c:
def __init__(self, a):
self.a = a
b = 4 # do something like this so that outside of class c,
...
I have started writing my own WebDAV server class in .NET, and the first class I'm starting with is a WebDAVListener class, modelled after how the HttpListener class works.
Since I don't want to reimplement the core http protocol handling, I will use HttpListener for all its worth, and thus I have a question.
What would the suggested w...
I have two classes, Car and Person. Car has as one of its members an instance of Person, driver. I want to move a car, while keeping track of its location, and also move the driver inside the car and get its location. However, while this works from inside the class (I have printed out the values as they are calculated), when I try to acc...
Hello,
To "simulate" instances from class diagrams I am using USE But I find very frustating to create instances. I am looking for similar tools like this one. I really like USE, but GUI is painfull. I think, that USE is pretty cool to learn how the model "works".
Do you know similar tools like this one?
...
I'm contemplating two different class designs for handling a situation where some repositories are read-only while others are read-write. (I don't foresee any need for a write-only repository.)
Class Design 1 -- provide all functionality in a base class, then expose applicable functionality publicly in sub classes
public abstract cla...
In Ruby, it seems that a lot of coerce() help can be done by
def coerce(something)
[self, something]
end
that's is, when
3 + rational
is needed, Fixnum 3 doesn't know how to handle adding a Rational, so it asks Rational#coerce for help by calling rational.coerce(3), and this coerce instance method will tell the caller:
# I know ...
I'm trying to designing a class and I'm having issues with accessing some of the nested fields and I have some concerns with how multithread safe the whole design is. I would like to know if anyone has a better idea of how this should be designed or if any changes that should be made?
using System;
using System.Collections;
namespace ...
I saw multiple examples in MSDN that uses to declare the internal fields at the end of the class. What is the point?
I find this a little embarrassing, because each time Visual Studio adds a method it adds it to the end of the class, so there is need every time to move it...
class A
{
public A(){}
// Methods, Properties, etc ...
...
I have created a class say A which has some functions defined as protected.
Now Class B inherits A and class C inherits B. Class A has private default constructor and protected parameterized constructor.
I want Class B to be able to access all the protected functions defined in Class A but class C can have access on some of the functio...
Hi all,
I'm not sure how to design a couple of classes in my app.
Basically that's a situation:
each user can have many preferences
each preference can be referred to an object of different classes (e.g. album, film, book etc)
the preference is expressed as a set of values (e.g. score, etc).
The problem is that many users can h...