Working on a little Ruby script that goes out to the web and crawls various services. I've got a module with several classes inside:
module Crawler
class Runner
class Options
class Engine
end
I want to share one logger among all those of those classes. Normally I'd just put this in a constant in the module and reference it like ...
So I have this
public class Foo
{
public int UniqueIdentifier;
public Foo()
{
UniqueIdentifier = ????
}
}
How do I get a completely unique number?
Thanks!
...
How would I model such a situation? How should the database be designed? What classes should I have?
Problem Statement: Each employee belongs at least to one project, each project has many tasks, each task is assigned to at least one employee.
I should be able to churn out
the employees working on a project.
the tasks that belong t...
OK, so I have a couple of modules in my application. One is called ProductCatalogue and another is called Contracts. We now have a need for a contract to be associated with a number of products (eg the products which a party to a contract is allowed to order). Within the ProductCatalogue module we have a ProductDAL class which has the fo...
Given the following tables: User, Trial, UserTrial. Where A user has multiple trials, a Trial does not internally map to any Users and contains details about the trial (name, description, settings), and a UserTrial contains information specific to an instance of a User's trial (expiration date, for example). What would be the proper way ...
I am tasked with pulling all the rows from a 3rd party vendor's SQLite data table, creating business objects from those records, and sending the new business objects off to another class.
Pseudo-code:
var databasePath = "%user profile%\application data\some3rdPartyVendor\vendor.sqlite"
var connection = OpenSqliteConnection(databasePath...
I'm wondering what the best approach is to verify that a class has all the required details before it can be used.
For example say I have a Book class and I want to pass in a set of properties about the book to the Book constructor.
Book book = new Book(bookProperties);
What I want to make sure that BookProperties is complete, i.e. h...
I came across a situation where I would like to step back through the app's methods up the "tree" until I decided to catch it (if I do) - like an exception; it's raised through all the code until you catch it or hits the roof.
The general concensus is that you only use exception for exceptions. That being the case, what would be the me...
What is the purpose of a marker interface?
...
I'm fairly new to the OO design process, so please bear with me....
I have two entities that I need to model as classes, call them Parent and Child (it's close enough to the actual problem domain). One Parent will have one or more Children -- I have not interest, in this application, in childless Parents.
Where my brain is going out to...
Consider the following situation
class URISplit {
var $REQ_URI;
//some more variables
function __construct($uri) {
//some code
$this->REQ_URI = $uri;
//some code yet again
}
}
and the following
class URIResolve extends URISplit {
//some variables
function __construct($uri) {
...
Edit: Though I've accepted David's answer, Jon's answer should be considered as well.
Which method is preferred for setting the value of a read only (get only?) Property: using a backing field or using the constructor? Assume the design is for a Property and not a Field (in the future, there may be an update that requires the Property t...
Hello SO-Followers,
I want to initialize a user configuration through a user configuration file. The path for the file can be read from the registry.
The file is located in a folder with the user's name.
So I need the following functionality:
Reading a string from registry
building the path to the configuration file
Reading the file ...
If i have a textgame that has a world object that has objects of type room which has objects of items and enemies and then a gamehelper object that has user objects for the actual player. (this game doesn't have wandering enemies since that would complicate my question to much for me :-))
How should I go about either killing an enemy or...
The answer to What is the correct way to make exceptions serializable? says that the "correct" base implementation for a custom exception includes 4 ctors:
[Serializable]
public class SerializableExceptionWithoutCustomProperties : Exception
{
public SerializableExceptionWithoutCustomProperties()
{
}
public Serializabl...
I consider fluent interfaces very convenient for many tasks. But I feel uneasy when I end up mixing fluent methods and modifying methods in one class.
Just an example (it's a little contrived, please bear with me):
Assuming a string utility class, trimming seems good for chaining:
Str & Str::Trim() { return TrimLeft().TrimRight(); }...
I'm working on a large project (for me) which will have many classes and will need to be extensible, but I'm not sure how to plan out my program and how the classes need to interact.
I took an OOD course a few semesters back and learned a lot from it; like writing UML, and translating requirements documents into objects and classes. We ...
Say I have a class that looks like the following:
internal class SomeClass
{
IDependency _someDependency;
...
internal string SomeFunctionality_MakesUseofIDependency()
{
...
}
}
And then I want to add functionality that is related but makes use of a different dependency to achieve its purpose. Perhaps someth...
Okay, so here's a problem I'm running into.
I have some classes in my application that have methods that require a database connection. I am torn between two different ways to design the classes, both of which are centered around dependency injection:
Provide a property for the connection that is set by the caller prior to method invo...
I have a table in a database that I'm mapping to a main entity class. The table has some columns that hold foreign key values to other attribute tables.
How do I map these to the business classes? Do I create a new class for every attribute table and have the primary class hold these as properties?
...