|
Hmm, I'd say it is as you say a higher level of abstraction and containing several individual design patterns.
I think I should write an article about that, that would make the discussion easier
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Hi Dear
as theory says singleton use is for making one instance available throughout the life time of application
As far as scenario is concerned the dbconnection is bad one as some one said becos of pooling. You can think of salary being credited and debited to employee accounts in banks. you can make sure this operation is implemented using singleton class can also make sure only the manager or single person in bank has access to this class.
Gokul- MCSD:MCAD:MCP - Technical Lead - GFT INDIA
|
|
|
|
|
Greetings Shakeela,
The Singleton design pattern serves to describe an implementation that restricts instantiation of a class to one object, in other words no copies or additional references. I've created a Singleton instantiate for you here to experiment with and get an idea of my description above. the singleton design pattern also belongs to the Creational Patterns group which consist of the following additional design patterns:
o Abstract factory pattern: centralize decision of what factory to instantiate
o Factory method pattern: centralize creation of an object of a specific type choosing one of several implementations
o Builder pattern: separate the construction of a complex object from its representation so that the same construction process can create different representations
o Lazy initialization pattern: tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed
o Object pool: avoid expensive acquisition and release of resources by recycling objects that are no longer in use
o Prototype pattern: used when the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) is prohibitively expensive for a given application
The singleton class you can experiment with:
<br />
public sealed class SingletonCreator<Type> where Type : class, new()<br />
{<br />
<br />
#region Private declarations<br />
private static Type instance;<br />
#endregion<br />
<br />
#region Properties<br />
public static Type GetInstance()<br />
{<br />
lock (typeof(Type))<br />
{<br />
if (instance == null)<br />
{<br />
instance = new Type();<br />
}<br />
return instance;<br />
}<br />
}<br />
#endregion<br />
<br />
}<br />
Usage:
<br />
MyClass myClass = SingletonCreator<MyClass>.GetInstance();<br />
I hope this helps you in your quest to learn design patterns Have an awesome weekend...
Fernando Mendes
Senior .NET Developer, Architect
|
|
|
|
|
singletons are used when it only makes sense to have exactly one and only one of them... i am not sure the impact singletons have on multi-threaded apps either, you might want to do some research in that area as well.
design patterns are an interesting concept... i always stick to the kiss principle.. and avoid over-engineering my code.
sometimes you can get into trouble with singletons, because sometimes they are implemented with private a constructor and destructor, and some example implementations you find on the web have nearly undetectable flaws ... there are variations to this theme between java and c++, and i am not sure about python (or whether you even need to do it in python).
be cautious and judicious in your decision making,
kind regards,
David
|
|
|
|
|
Hi,
I need to develop three applications over LAN. One is the core application, written in C++ and the other two are clients application.
The two clients application are GUI for the core application, they don't run on the same machine.
Can you advise me what kind of technology to use for communication between them?
I prefer to write the GUI application in C# or V.B .Net
Thanks
Yoav Zur
|
|
|
|
|
|
Hello,
I'm building a base class to hold information taken from a robot movement file.
This means I have several lines, each with a set of points, and sometimes commands, between the points. Each point has some data (coordinates, orientation, zone, speed, work object, and a few more).
I'm using Eran Kampf's Sharp3D math library.
I would like a sugestion on how to implement the base class.
So far, I've done the following:
using Sharp3D.Math.Core
using Sharp3D.Math.Geometry3D
namespace ModelClass
{
#region Class constants
public enum Linetypes
{
undefined = -1,
laser = 0,
water = 1,
glue = 2,
primer = 3,
rough = 4
}
public enum Polysides
{
undefined = -5,
none = -1,
right = 0,
left = 1
}
#endregion
public class Point7D
{
// Represents a point in 3D space
Vector3F point;
// Represents the quaternion of vector associated with point
QuaternionD quaternion;
// Point name descriptor
string name;
}
(...)
public class RobotPoint : Point7D
{
#region Constants
public enum zones
{
undefined,
fine,
z0,
z1,
z5
}
public enum speeds
{
undefined,
v5,
v10,
v100,
v1000
}
const string ActiveTool = "ActiveTool";
const string AuxPointData = "[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]";
#endregion
#region Internal fields
// Workplace definition
string workplace;
// Tool defined for the point
string tool;
// Zone definition
zones zone;
// Speed definition
speeds speed;
#endregion
}
public class PolyLine7D
{
#region Internal Fields
List<RobotPoint> pointList;
string name;
Linetypes type;
int width;
int npasses;
int npts;
int power;
Polysides polyside;
#endregion
}
public class Model
{
#region Internal Fields
double front_tolerance;
double back_tolerance;
double inside_x_sep;
double outside_x_sep;
double plan_overlap;
List<PolyLine7D> _ModelPolylines;
string _ModelFileName;
#endregion
}
}
Should the class PolyLine implement itself a static method for creating a list, instead of having the Model class do it?
Same question for the Model class if I want to have more than one file opened at the same time? In such case, I would create a Hashtable, with the _ModelFileName as a key.
Thanks for any help you can give me.
|
|
|
|
|
Have you come up with any good ideas?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Dear All,
I've designed the basic retail management solution. Now my client is asking me include the promotion management into the system by each product or all. I hoping some guidance from whoever have already designed before. Mostly I'm looking at the database perspective (table design). the design should be flexible, it should cater for the following conditions:
* Buy X at a Discount (% or value)
* Buy X, Get Y at a Discount (% or Value) or for Free
* Buy N Qty X, Get Y at a Discount (% or Value) or for Free
* Buy X &Y, Get X at a Discount (% or Value) or for Free
* Buy X, Get X, Y & Z for Free
Hope somebody will give flexible design for the above mentioned combinations, there can be many more combinations, but i can only think of this for the moment.. If i missed out, kindly add up for my knowledge.
Regards
Yamiho
|
|
|
|
|
Have you come up with any good ideas?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
plz can someone help me to get a FREE version of infragistics NetAdbantage for .Net from onother source of "www.infragistics.com" ?
|
|
|
|
|
Have you tried "infragistics.com"?
|
|
|
|
|
hi how are you
im name RAJA
where are you live
|
|
|
|
|
He wants it free ... i.e. warez.
Not only that but a cross post hehe.
|
|
|
|
|
While running my service i got Fault Exception Error "An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail."
Any one can help me pls.....
|
|
|
|
|
If anybody can send me State Machine Diagram for client-server communication,please send me as soon as possible.
Thanks
|
|
|
|
|
You're joking, right? Why should anyone send you the documentaion they wrote for their own systems?? Considering that this is a security risk in any organization, I seriously doubt you'll ever get someone to hand over their doc's...
|
|
|
|
|
Hi
I have been pondering this "problem" for a while now and thought I'd submit it here for some more ideas. (Hope I chose the right message board.)
Scenario: an application that allows users to generate quotes, obviously the quotes need some sort of sequential numbering. The problem is that it is a semi-connected application so the user could be generating the quote offline.
Question: What is the best way to go about generating a quote (reference) number?
Some of my ideas: the 1st would be something like a date-time stamp (including miliseconds) but this makes the number to long. You don't want the client reading a 16 digit number for reference purposes. I also though of including a type of employee code to increate the uniqueness but I don't think it will help too much.
Am I missing something or is this fairly impossible to do? Your comments will be great.
Thanks
Francois
|
|
|
|
|
In a semi connected environment its going to be extremely difficult to pull off sequential numbering at all. I'm assuming this is the scenario:
1. Your field guys may disconnect
2. Create an arbitary number of quotes
3. Give the client their quote number on the spot
4. Return and resync.
Point 2 can be solved if you can get them to create a pending quote on the way out for all their appointments, this might be a workaround. Point 3 prevents you from ever changing the quote number on resync, so you need to be certain its good.
I'd question the need for exact sequential numbering. Typically accountanty people like their invoice numbers to be sequential, but this doesnt prevent you from giving a reference number that can be generated on the spot. Generation would depend on your environment, something like field guy id dash, sequence number.
|
|
|
|
|
Thanks for your input Mark
I will definitely interrogate the reasoning behind HAVE TO HAVE a sequential numbering.
I thought of a workaround similar to your pending quote and that is that the field guy prerequests a few seq-reference numbers which is then allocated to him. No more allocated numbers left = can't create quote.
|
|
|
|
|
Does the quote ID have to be numeric or could you use a string? Does it have to be sequential or just unique within the system?
How about a combination of unique employee ID and time? Assuming it takes longer than a second to generate a quote then you would only need the date-time stamp with seconds. You could then encode this as a string in base 36 (all 26 letters and 10 numbers)
|
|
|
|
|
I am unable to install ODP.Net 2 version.
Does anybody have its installation steps
Thanx,
Mini
|
|
|
|
|
Have you looked into their documentation?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I'm looking at using RDL to define flat file exports, being the sections of the file and the record layout of the sections. It seems quite appropriate as many of the RDL elements already cater for grouping and totalling etc. I would just like a few pointers to resources on generating the RDL and maybe extending it slightly, to cater for fixed length fields etc. if anyone can steer me in the right direction.
"Once in Africa I lost the corkscrew and we were forced to live off food and water for weeks." - Ernest Hemingway
My New Blog
|
|
|
|
|
Hi all,
I am newbie here.
My Tech. environment: .Net and Sql Server
Problem:
Manyatimes, we need to return data from different tables in the database to the UI (for example, search results) whose schema wouldnt match with any of the domain objects.
In this case, one option is to transfer the data using the datasets/datatables feature provided by .Net.
The other option I could think of is to create business (DTO?) objects to just pass on the data from the DB to the UI.
I prefer the second approach. However, I need suggestions on how do I implement it? Will this DTO contain a reference of all the domain objects involved or Can I just include only the desired columns?
Or, do we have any other solution?
Thanks in advance,
AGL
|
|
|
|