|
This is really just a contraction of the Factory patterns. Basically, we have Concrete and Abstract Factory patterns.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Yes, of course there is factory pattern.
It's something like this:
==
==
=
__
||
||
/|/|/|/ |/|
| [] [] |
| |
Slow day at work, eh.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
flyingxu wrote: Is there really a pattern named 'Factory', or it's just something in Java?
Yup, software patterns are language independent.. see it as a concept with a name, it makes commucation between developers easier (once they know the meaning of a pattern).
Here one example of use for a factory in C++: A plugin (in form of a shared library) has typically one static function in a DLL that creates and returns a new plugin instance/object to the caller.
Hope it helps.
|
|
|
|
|
Yes you can create a class which can provide you the desired objects.
such class can be a Factory.
Stack *pStack = CFactory::GetStack(n);
where n -> type of stack.
Sameer();
|
|
|
|
|
hello friends
i don't think this is the right forum ...
but i'm going to design the application ...
i need buttons to put in the toolbar and on buttons to give a fine look for the presentation of my application .
can anybody helps me ???
thanks
|
|
|
|
|
|
|
|
|
Hello guys and girls,
I've got a generic architecture best principals question for you I as hoping people could give me some pointers on (or at least, generate some discussion over). The issue I've just encountered is as follows:
I'm generating a plugin for a service. My plugin will be compiled as a stand alone dll and called from an application.
There are two stages of execution for the plugin: 1. Set up as part of a winforms application, then 2) execution as part of a windows service.
In generating the setup information I specify a list of types of "Email Processor" class to use, where EmailProcessor is an abstract class and each type of email processor extends that abstract class to create in instance class.
In saving the settings, the list of EmailProcessors was to be saved using XmlSerialisation (this is functionality of the parent application and not my plugin), which throws an error since the type of the EmailProcessor is dynamic. I can't implement any sort of custom XmlSerialisation so I have had to make the abstract EmailProcessor class into a real (non-abstract) class and then throw a NotImplementedException from each of its methods.
This has obviously broken the basic inheritance model slightly - not so much as to be truly irritating but enough to make me think there was probably a more correct way of approaching the issue.
Can anyone suggest to me what I should have done to allow EmailProcessors to maintain their inheritance model but overcome the issues I had with getting round the XmlSerialisation of dynamic types that I had no control over?
Any thoughts greatly appreciated.
Cheers,
Adam
|
|
|
|
|
|
Hi Joseph,
Thanks very much for the response, but unfortunately (as was mentioned in my original request but perhaps could have been made clearer) the plugin architecture is already in place as part of an application that is already live on a number of systems. The only reason for mentioning the plugin architecture is actually to define the constraint the my settings must be stored using XmlSerialisation, which is what causes my problem in implementing a proper inheritance model.
Thanks for your help, I appreciate you taking the time to respond.
|
|
|
|
|
I might not get your complete plugin design... however I'll try an answer.
How about a plugin impements an interface (e.g. pure abstract class in C++), one method could be OnSerialise(HFILE hFile) . Whenever the application needs to serialise data it will find the corresponding plugin and request it to serialise its data by calling pPlugin->OnSerialise(). The file handle is just an example in case you want that multiple plugins write into the same file.
Here an example plugin interface, the first two methods are generic:
class IPluginInterface
{
public:
virtual int GetVersionNumber() const = 0;
virtual void DeleteThis() const = 0;
virtual bool OnSerialise(HFILE hFile) = 0;
virtual bool OnDoStuff(int nEvent) = 0;
};
|
|
|
|
|
I did consider the use of interfaces to get round the problem, but unfortunately XmlSerialisation will still stumble on the main issue that I'm trying to store a list of EmailProcessors that would all have different types.
The only way I came upon to get round this was to cast down to an actual instance of the parent type to store my setting and use a string within the parent type to allow me to cast back up to the appropriate child type after serialisation once the plugin is running.
Is there a more correct solution or is this the only way round the dynamic typing issue caused by an XmlSerialisation process that I can't modify?
Thanks very much for taking the time to respond - it is appreciated.
Cheers,
Adam
|
|
|
|
|
NamelessParanoia wrote: main issue that I'm trying to store a list of EmailProcessors that would all have different types.
I think the solution could be using polymorphism in your design. I understand from your description that your serialiser needs to get the appropriate data from each EmailProcessor (each processor could be internally handle a different type). In C++ language I would suggest to derive EmailProcessor from an interface that has a pure virtual method such as virtual void GetEmailData(buffer) = 0 , in different EmailProcessors you would specialise this method differently. Now, the serialiser can collect data from any EmailProcessor in (step one), then convert the collected data into a valid XML tree (step two).
Hope it helps,
Mark
|
|
|
|
|
Hello,
Can anyone gimme some pointers, links, Ideas, ways, thoughts about
(a) Deriving from a Singleton Instance Class.
(b) Having a Distributed Singleton instance Class across machines and processes where by we can instantiate a class on one and only one machine / process?
Thanks and regards,
-Chetan Kudalkar
Chetan Kudalkar
|
|
|
|
|
hi everyone,
I'm making an accounting software for an organization for the first time and I've designed a ledger table as Ledger(ID, TDate, Debit, Credit, Balance)
The balance field is a calculated field. And I was wondering how should I program its update and delete triggers. Can u plz give me a few useful tips on this.
thanks
Rocky
|
|
|
|
|
|
Don't forget FUTURECAT1, FUTURECAT2 etc. Geez I am not even a DBA but please that is just poor even for you.
led mike
|
|
|
|
|
The Grand Negus wrote: I suspect you're misinterpreting my previous post.
It would seem so.
led mike
|
|
|
|
|
thank u so much for ur reply, I really appreciate this,
I c that u have designed many accounting systems successfully with this design. well I have already done a lot of work on the design and I thought I should tell u abt my design as well. I have designed the a journal table so that the daily transactions should be recorded in that and these transactions are posted automatically to the ledger table where the balance is calculated automaticaly even in teh case of an insert, Delete or update opration. There was another requirement that automatic posting should be made to the journal while making a new bill, which offcourse will go to the ledgers as well. So far I havent seen any sub categories of accounts in my organizations case. when the balance field shows a positive amount, it means that its a credit balance and otherwise its a debit balance.
So how does it look
hope to hear ur comments on that, thank u for ur time.
Rocky
|
|
|
|
|
Well since yesterday I've been wondering about the second issue ur talking abt i.e
The Grand Negus wrote: (2) keeping a record of what actually happened when updates and deletes are made.
I was wondering what I should do in that case. Should I completely disallow updates and deletes and let the user modify the previous entry with another transaction in the journal. My desgin is like this
Generaljournal(journalID, Debit, Credit, Particulars, TDate, AccountID, billID)
Accounts(AccountID, Title, StartDate, CustID, PartyID, IsActive)
PartyID(ID, Name, Address) -- the parties from which we purchase
LedgersDetails(ID, TDate, Debit, Credit, Balance, journalID, EmpID)
Bill(BillID, CustID, TotalWeight, EmpID, Rate, TotalAmount, Discount, Coneweight, NetWeight, BillDate )
Sale(SaleID, BillID, prodID, PackageWeight, PackageCount, Rate )
Product(ProdID, Name, TypeID, Size, IsObsolete, Pic, IntroDate)
Cust(CustID, Name, Address)
Emp(ID, Name, FathersName, NIC, pic, levelID)
Type(ID, Name)
ProdSize(ProdID, SizeID)
Size(ID, title)
Users(UserName, Password, EmpId, LoggedIn, Last_LoggedIn)
UserLevel(ID, Name)
---------------
phew!! so thats just abt it for the design and as I was saying, well the problem i was wondering abt is the updates and deletes in generalJournal, So Now What do u say... Is that a good idea that I should just let the user update or delete a record in journal? well if u ask me its pretty dangerous coz there would be no clue who did all that.
on the other hand,
how should the user edit/ Cancel a previous transaction by makinga new entry in the database? probably the reason y I'm asking thsi is the lack of my indepth knowlege of accounting.
Please give me a few guideline on this issue.
Rocky
|
|
|
|
|
The Grand Negus wrote: Incorrect entries are modified or effectively (but not physically) removed by entering new, offsetting entries in the transaction tables
I got ur point now but how can I put these offseting entries in my design now. Or is it that I have to change it to some other form. I was thinking I should make an extra table to log the updates/deletes but that would also not be an offsetting entry. What change should I make now??
you also said
(1) keeping the daily transactions synchronized with the ledger
What does that mean... can u plz expplain that a little bit.
|
|
|
|
|
|
well yes, offcourse u can't design this thing from over there.. my question was invalid at the first place.
Firstly I have designed this thing such that the user will access only the Generaljournal table while the ledgerDetails TAble will be kept sycronized via coding in the triggers. So I think that makes the LedgerDetails teh Summary table right? I'm not too sure abt teh meaning of a Summary table at the moment though
Now I'm thinking abt making another table for recording the transactions but I think I need some time out now. I need to do some brain storming again.
see u tommorow with another idea I hope so. thanks for ur help
Rocky
|
|
|
|
|