I've asked myself this question a number of times when creating classes, particularly those involving collections, but I've never come up with a satisfactory answer. It's a OOP design question.
For example, in a checkbook register program say I have a class of BankAccount. BankAccounts contain data involving the Name of the account, the...
Basically I have a class that sends a SOAP request for room information receives a response, it can only handle one room at a time.. eg:
class roomParser {
private $numRooms;
private $adults;
private $dailyPrice;
public function parse(){}
public function send(){}
};
$room = new roomParser( $arrival, $departue );
$...
I have a class that outputs a simple report file. It reads some record ID numbers from an XML file: each one used for finding a matching record stored in a database. It then writes out each record's details to a CSV file.
I am wondering - what is the best way to organise it so that it is easy to test, yet follows the principles of encap...
In C#, what is the purpose of marking a class static?
If I have a class that has only static methods, I can mark the class static or not. Why would I want to mark the class static? Would I ever NOT want to mark a class static, if all the methods are static, and if I plan to never add a non-static method?
I looked around and saw some...
I am designing a class library which will be used like this:
Engine eng = new Engine();
eng.AddPart(part).AddPart(otherPart).Run();
The problem with the class is that the parts are kept by the engine so if you want Run it with some other parts you will need to remove the ones that you have already added. There are several possible ...
I have a class that has to take product information from one system's database and save it to another system's product database.
I'll call a product from the first system Product A and the other Product B. Product B's data depends on settings selected from a user.
So Product B may have a GetDescriptions method that looks at a user se...
I have a static class that contains my database logic.
This class is used in a website, web services and as part of a middleware component.
For every method in this class I need a piece of context information from the caller. In the case of the web site this would be user information, for the web service and middleware component, this...
I am a beginner to programming when i start to code i just start writing and solve the problem .
i write whole program in a single main fuction.
i dont know when to make class , and functions
what are good books which i read to learn these concepts
...
The gist of this question is about extending a class, minimizing jam-packing everything into a single class, and maximizing code re-use. After reading this question, please feel free to edit the title or description to make it more succinct. Though the post looks long, I am just trying to be thorough by using a lot of examples.
Suppose ...
Do I have create extra method for this kind of assignment? @@variable = @global_variable Why? I want to have some variables that hold values and definitions to be accessible all through my script and have only one place of definition.
@global_variable = 'test'
class Test
@@variable = @global_variable
def self.display
puts @@va...
I am moving to C++ from Java and I am having a lot of trouble understanding the basics of how C++ classes work and best practices for designing them. Specifically I am wondering if I should be using a pointer to my class member in the following case.
I have a custom class Foo which which represents the state of a game on a specific turn...
First, my latest coding is Java, and I do not want to "write Java in C++".
Here's the deal, I have to create an immutable class. It's fairly simple. The only issue is that getting the initial values is some work. So I cannot simply call initializes to initialize my members.
So what's the best way of creating such a class? And how c...
Say I have two separate classes, A and B.
I also have Repository class C which loads some information from a textfile. E.g. It has methods loadLines(), addLine(), deleteLine().
Ignoring databinding, how can I make A and B both work on the same class C. Is it possible?
For example at the moment, in class A and B formload, I have:
var...
I'm studying some source codes and I'm just wondering why a class (or classes) is often implemented this way:
class EventHandler
{
...
EventDispatcher* m_Dispatcher;
virtual bool ProcEvent( EventHandler* Sender, int Task, int Event, void* Param );
...
};
class ClassA: public EventHandler
{
...
ClassA* m_Impl;
ClassA* m...
The function of the class:
Receive a sequence of image frames, the sequence is infinite.
Detect if there is motion in the frames.
Group motion frames according to certain algorithm.
So far the design is(pretty silly):
class MotionDetector
{
//detect motion in the frame, return true if the group is captured.
//frameToDi...
I was recently reading Rob Conery's post about DB4O and it was very interesting. My question is really concerned with class generation and future use of Subsonic and DB4O.
As Subsonic looks at the database and then generates classes how would this work for DB4O. Would the classes have to be written by hand and then DB4O would store th...
I have a class, let's say Person, which is managed by another class/module, let's say PersonPool.
I have another module in my application, let's say module M, that wants to associate information with a person, in the most efficient way. I considered the following alternatives:
Add a data member to Person, which is accessed by the oth...
It is somewhat known where .NET keeps value types in memory (mostly in stack but could be in heap in certain circumstances etc)...
My question is - where is the code of the struct?
If I have say 16 byte of data fields in the struct and a massive computation method in it - I am presuming that 16 byte will be copied in stack and the met...
I read Cwalina book (recommendations on development and design of .NET apps).
He says that good designed struct has to be less than 16 bytes in size (for performance purpose).
My questions is - why exactly is this?
And (more important) can I have larger struct with same efficiency if I run my .NET 3.5 (soon to be .NET 4.0) 64-bit ap...
Reading a book I have found the following statement:
(Object) Behaviors answer either of two questions: What does this object do (for me)? or What can I do to this object? In the case of an orange, it doesn’t do a whole lot, but we can do things to it. One behavior is that it can be eaten.
In my understanding of object behaviour th...