class-design Questions

8

I am programming a simple role playing game (to learn and for fun) and I'm at the point where I'm trying to come up with a way for game objects to interact with each other. There are two things I a...
Rozella asked 1/2, 2010 at 19:57

1

I'm attempting to write a reusable parsing library (for fun). I wrote a Lexer class which generates a sequence of Tokens. Token is a base class for a hierarchy of subclasses, each representing dif...
Wintery asked 9/9, 2011 at 13:13

3

Solved

I have a factory class that creates objects with circular references. I'd like them to be immutable (in some sense of the word) too. So I use the following technique, using a closure of sorts: [&l...
Quondam asked 11/8, 2011 at 19:54

7

Solved

The large majority of my programming knowledge is self-taught, so I was never taught proper design patterns, conventions, and so on and so forth. I've been digging through a lot of my company's so...
Hin asked 26/7, 2011 at 4:15

4

Solved

Possible Duplicate: When should you use 'friend' in C++? I have come to a stumbling block because of lack of documentation on friend classes. Most books just explain it briefl...
Ulaulah asked 16/7, 2011 at 15:5

2

Solved

I am very familiar with JavaScript and OOP but am very unfamiliar with designing JS classes that are used for programming the UI (HTML). I have searched around a bit but have not come across any pr...
Tupler asked 5/7, 2011 at 5:1

0

This was asked as an interview question. Design a tic tac toe using object oriented principles. The interviewer said he is not interested in the logic and he wants only the design. I gave t...
Urbano asked 4/7, 2011 at 13:30

4

Solved

If my class uses disposable resource in it's constructor (DbConnection if it matters) should I implement IDisposable in my class and dispose DbConnection object, or let user handle disposal of DbCo...
Savannasavannah asked 24/6, 2011 at 12:18

4

Solved

I'm working on a lil' game engine in C++, and decided to do it all OOPily (heavy use of classes.) It's intended to be (theoretically) cross-platform, so I have an 'Engine' class, an instance of whi...
Misdemeanor asked 2/6, 2011 at 21:50

4

Solved

I have put several instances of class b in class a but this causes an error as class a does not know what class b is. Now I know I can solve this problem by writing my file b a c but this messes ...
Triplett asked 31/5, 2011 at 13:2

5

Solved

I've got a class called List_Field that, as the name suggests, builds list input fields. These list input fields allow users to select a single item per list. I want to be able to build list input...
Pupa asked 15/5, 2011 at 13:3

8

Solved

Suppose you have a class that is frequently (or even exclusively) used as part of a linked list. Is it an anti-pattern to place the linkage information within the object? For example: public cl...
Haywoodhayyim asked 23/5, 2011 at 14:24

3

For a while I have been thinking about how to deal with objects which are assigned identifiers by the database. A typical object representing a table entity may look like: public class Test { pu...
Progestin asked 17/5, 2011 at 14:20

3

Solved

I have a similar problem to the post Accessing a static property of a child in a parent method. The preferred answer hints that the design of the classes is faulty and more information is needed to...
Septuagenarian asked 16/5, 2011 at 16:10

4

Solved

Over time I have come to appreciate the mindset of many small functions ,and I really do like it a lot, but I'm having a hard time losing my shyness to apply it to classes, especially ones with mor...
Quiff asked 12/5, 2011 at 10:18

3

Solved

I encountered a strange bug in python where using the __new__ method of a class as a factory would lead to the __init__ method of the instantiated class to be called twice. The idea was originally...
Audra asked 10/5, 2011 at 17:11

5

Solved

I have a simple, low-level container class that is used by a more high-level file class. Basically, the file class uses the container to store modifications locally before saving a final version to...
Gman asked 9/5, 2011 at 23:20

2

Solved

Possibly Related: Why don't PHP attributes allow functions? Pardon me if this has been asked before, but why can you not have something like the following: class foo { require_once '...
Getty asked 5/5, 2011 at 16:26

4

Solved

I have two objects, RoomManager and Room, there will be several Rooms and one RoomManager. I want the RoomManager to be the only one allowed to create a Room object. So I'm wondering if there is a ...
Youmans asked 13/4, 2011 at 7:6

7

Solved

I have class called Chicken and in Chicken I have some methods, so in another class where I instantiate and call methods on Chicken, I might do something like this: Chicken chicken = new Chicken("...
Slight asked 8/4, 2011 at 14:49

5

Solved

I have been trying to figure out the best way to use bitmask or bitfields in PHP for a long time now for different areas of my application for different user settings and permissions. The farthest ...
Earth asked 21/3, 2011 at 16:23

6

Solved

When programming C++ we used to create copy constructors when needed (or so we were taught). When switching to Java a few years ago, I noticed that the Cloneable interface is now being used instead...
Suprarenal asked 23/12, 2008 at 6:30

5

Solved

I am just getting started with .NET ORMs, to the point where I haven't even decided between Entity Framework and NHibernate. But in both cases, I'm running into a problem in that they seem to want ...
Ravi asked 19/3, 2011 at 19:59

2

I have two classes which in one aspect work together tightly. They both use functionality of each other that should be only used by them and not by any other class. Is it bad practice if I make t...
Pluralism asked 5/3, 2011 at 13:11

2

Solved

I have an app that is essentially a wrapper for a 3rd party API. The app does not use a database and only stores a single cookie which is the session ID that the API requires. The API is a shoppin...
Musketry asked 8/1, 2011 at 15:31

© 2022 - 2024 — McMap. All rights reserved.