I'm trying to write the most secure singleton in Ruby that I can. I'm new to the language, which is so elastic that I don't have a strong feeling that my singleton class will be successful at creating only one instance. As a bonus, I'd like the object to only become instantiated if really used.
Thanks!
...
So, I'd like to hear what you all think about this.
I have a project where three different inheritance paths need to all implement another base class. This would be multiple inheritance and isn't allowed in C#. I am curious how I can implement this without code duplication.
EDIT: I don't own the three classes. The three classes are f...
I guess I've asked a few similar questions before, but I was beating around the bush. I think this is the real problem that I can't quite lay to rest.
I'm dealing with a third party library, and there's an object that can't create itself, b2Body. The b2World has to instantiate it. I personally don't like this design pattern very much; I...
Hello,
I have a ecommerce site that has 2 types of products: books & seminars participations.
They are different, and have different attributes.
I am curious how would you model this in the DB and as models (since you cannot inherit multiple classes)
Right now i have something like:
DB
products (id, name ....)
seminars (id, title, da...
Hello,
I have a working solution in java using a classic state design pattern and facing some difficulties translating it to ruby. I am new in ruby, but the diffuclty I believe lies in the differences on how patterns can be implemented in dynamic languages.
My interface is describing the actions the model can execute in every state:
p...
I'm looking for advice on the best way to structure my program. Here is what I have now, and the problems I see with the design:
I have a class with a private constructor and a submit() method, to carefully control the objects created, and every object created is added to a global list. The program has several functions that perform "bi...
I'm designing an API for the first time, and trying to follow SOLID guidelines. One of the things I find myself struggling with is balancing OCP and testability with simplicity and ease of extensibility.
This open-source API is geared toward scientific modeling and computation. The aim is that various groups will be able to easily impor...
Hi Guys, a bit of help.
I have an application which executes multiple queries (query1, query2, query3) against a DB, retrieves data and then publishes that data.
The way I went about designing it was:
a. Have a DB class which encapsulated the connection, query execution, transforming resultset to POJOs.
b. A publisher class which kno...
Hi
Assume we create 3-tier module, which enables us to display/create/edit articles. Articles are:
• organized into categories
• before article can be published, admin has to approve it by setting Approve field of Articles DB table to true
• by setting MembersOnly field ( Articles table ) admin can also specify whether particular ...
I am creating a sample, application to understand repository and factory method patterns together, because will use in a bigger project.
What i want to achieve is be able to make the website work with different ORM tools.
For example the website will have LINQ to SQL and Ado entity frame work classes implemented then using the factory ...
1) There is Somelib which is added as jar in SomeProject.
2) In SomeProject there is the somePackage.SomeClass which implements SomeLib.SomeInterface.
3) SomeLib must be able to create somePackage.SomeClass instance without building SomeLib each time
How is it possible without using reflection? It's impossible to write in SomeLib some...
Recently i get in touch with Empire-db. The project doc. stated that they are using "string-free coding", intended to use less constant strings as possible to avoid typos and use the force of the compiler.
I was always a big fan of this principle, because i think as Java is a formal language it could be expresive for configuration like...
I have a system where users insert many types of things ("incidences") and all of them have to be approved by an admin. Which pattern will be useful for this case? Maybe validation is not the word for this.
Update: The problem is that the db where the data resides can't be changed. All the moderation things will be done in another db an...
I'm looking book/online resourses about JEE application deployment pattens. Especially I want to know patterns when to use local interfaces when remote ones (how many nodes I need to?). The key question is to use single EAR (EJB and WAR) or separate nodes for EJB and WARs.
Resources I've found are bitty outdated, they concentrate on EJB...
This is a generic C++ design question.
I'm writing an application that uses a client/server model. Right now I'm writing the server-side. Many clients already exist (some written by myself, others by third parties). The problem is that these existing clients all use different protocol versions (there have been 2-3 protocol changes over ...
I was looking for a Command pattern implementation in Python...
(According to Wikipedia,
the command pattern is a design
pattern in which an object is used to
represent and encapsulate all the
information needed to call a method at
a later time.
)
The only thing I found was Command Dispatch pattern:
class Dispatcher:
...
I had this code from a previous question, but its not compiling:
public interface IEntity
{
// Common to all Data Objects
}
public interface ICustomer : IEntity
{
// Specific data for a customer
}
public interface IRepository<T, TID> : IDisposable where T : IEntity
{
T Get(TID key);
IList<T> GetAll();
void S...
I am in the process of designing a feature for a system where I strongly feel that there must be a pattern for this out there, that I should know about before diving into the code.
The scenario is this:
I have a pool of resources of which I have a limited number.
I have a variable number of consumers that use those resources; each c...
Hello stack overflowers, I have a desing that uses the flyweight pattern to share bitmaps that are shared between bitmap objects which manage drawing ops, etc. and integrate in the gui library. This is an embedded device so memory is at a premium. Currently I have done a working implementation with a std::vector of auto_ptr of a light cl...
I knew than one of the benefits from using repository pattern make it easy to switch between ORM, for example will implement data access code using Linq to sql and also using Ado.net entity framework, then using Dependency injection switch which one to use.
I saw KIGG doing the same "but its class diagram is complicated a little, at lea...