|
class A
{
public:
...
AddTo(CList &L);
private:
}
For the bad, A is couple with CList.
For the good, A knows the knowledge to fill CList. But I think it's not necesary for A to know CList.
Is it better to write a gobal function, like:
bool FillList(CList &L, const class &A);
|
|
|
|
|
Why do you want to write a function for that ? CList probably has a function to do that (are you talking about MFC CList?). If not, then you should put this function in CList.
|
|
|
|
|
For polymophism,
class A {
public:
virtual void Fill(CList &L);
}
class B : pubic A
{
public:
virtual void Fill(CList &L);
}
class C : pubic A
{
public:
virtual void Fill(CList &L);
}
If I get a object refereced by A *p , I may call p->FillList(L) .
In another sense, the object knows what to add to the list, it's a reason to add such a memeber function.
The bad thing is that they are coupled.
|
|
|
|
|
The list handles perfeclty adding polymorphic objects to itself. So, what's the problem ? Why do you absolutely want to have a function in class A ? That doesn't make a lot of sense to me. Of course, your list should store pointers to A, then you can add B or C objects to the list and keep the power of polymorphism.
|
|
|
|
|
I haven't say it clearly.
The case is that class B or C has a lot a members to add to the list.
class B : public class A
{
public:
virtual void AddToList(CList &L);
private:
long m_var1;
long m_var2;
long m_var3;
}
|
|
|
|
|
followait wrote: The case is that class B or C has a lot a members to add to the list.
Ooookayy. That was not clear at all from the begining: you don't want to add the object itself to the list but the object should add some elements in the list. In that case, I would make it a member function of the class.
|
|
|
|
|
Class A only needs to have a method AddToList.
I am visualizing from example that List is going to contain only pointer of Class A. Then base class object can point derived class object so basically this method not need to make virtual.
Even though if list is going to have copy of object then need to implement copy constructor & assignment operator in each derived class to make appropriate copy.
But from my point of view class responsibilities should not be mixed up it should be some controller class responsibility to collect object in list rather then Class A itself. So writing a separate method in any other class is better from design-wise. Or make a another class derived by CList and create a method e.g say: "CollectDataInList(A *a)" or have this method in class which is containing CList object.
Akash
|
|
|
|
|
Hi People,
I have an ACE placed on a user control.
If no matching results are found for the criteria supplied I display --> No match found. Please select the item that matches your field of expertise.
This is a bit late and maybe less intuitive.
What I would like is to place a non selectable item in the result list at the very bottom. It would say --> Please select the item that matches your field of expertise.
The result list would then look like this below.
Finance
Clerk
Developer
Trader
Retail
etc
--------------------
Please select the item that matches your field of expertise
Is this possible at all?
Many thanks
|
|
|
|
|
wantToLearn wrote: Is this possible at all?
Yes.
|
|
|
|
|
We are developing a smart client application which consists of shell application with Deck workspace.
Hence we are showing all the UI elements (views) in an overlapped manner. In a particular view, we have an explorer bar which loads group of text editors and combo box editors controls and Save/Cancel buttons. I have given the tab order in a sequence (0 1 2…). But while traversing through that particular view, have noticed that after cancel button the tab order going to next view instead of focusing the initial field in the same view (page).
Thank you.
Regards,
Divya
|
|
|
|
|
Welcome to CodeProject
Take some time to look through the forum list and try to find one that more specifically matches your problem. It seems your problem has nothing to do with Design or Architecture. Many of the forums are specific to languages and/or platforms and it seems that is the problem you are dealing with, how the tab control works and perhaps the IDE you are working with.
led mike
|
|
|
|
|
Hi,
How can I design a business use case diagram?
I know how to design a use case diagram, but what is business use case diagram?
I'd searched the web, but I did't give my answer.
Best wishes
|
|
|
|
|
|
Uses case fundamentally has two kinds: business use case & system use case.
Both have same way of presentation and almost same templates.
If you have wrote use cases more towards to defines yours system or in other words interaction between different systems or interaction with system and human then they are more towards system use case. (e.g presenting available menus and their interaction).
Business use cases are more towards to define business (e.g presenting available menu and their broad view of features)
You should take another try to search material into web, lots of material available
Akash
|
|
|
|
|
Hi Gurus,
I'm trying to create a website with scalability in mind but I'm a little stuck with ASP.NET authentication (Forms Authentication) because I simply don't know much about its internals. I wonder how high traffic websites like myspace.com handle authentication. Most pages in my application are public (i.e. accessible to anyone authenticated or not), only a few pages are only available to authenticated users. I'm basically trying to find answers to those questions:
- As far as I understand from the documentation, ASP.NET Forms Authentication authenticates every request, ie. checks for the authentication cookie and if found it extracts the authentication ticket and decrypts it, is my understanding correct? And if so, can't this potentially affect performance esp. the decryption part? Is this needed for renewing the authentication cookies? (as I believe the ticket issuance time is saved inside the ticket so probably the cookie has to be decrypted anyway to get the ticket issuance time from the ticket then compare this to the current time and decide whether the cookie has to be renewed). If this is an absolute necessity (I'm talking about authenticating every request for the sake of cookie renewal), can we use an encryption algorithm with low overhead (in web.config, authentication element), still efficient? which encryption algorithm would you recommend in this case?
- Is there any way I could make ASP.NET only authenticate requests to protected pages (=pages that are only accessible to authenticated users), BTW, in my application I don't use roles I only make those pages accessible to any authenticated user. Actually I read somewhere that I could write the code needed to authenticate the user only in those protected pages but I wonder whether I will have to handle cookie renewal in this case (this is one thing that's automatically handled by ASP.NET forms authentication)
- Any ideas how I can get the last login with a persistent cookie? In my application I want to allow users to use the "remember me" option (which will send a persistent cookie to the user's computer), now the user doesn't log on explicitly anymore, so I can't put my code that saves the last login to the database in the login page hence it's not used by the user anymore, so how can I do this? I'm thinking about one way to do it but I'm a little worried about how this could impact performance, anyway, here's how .. in my application I need some user related data so I could probably get the data from the database whenever a user with a persistent cookie visits the site (probably FormsAuthentication_Authenticate is the most suitable place) and also write the last login to the database then cache the user data in ASP.NET's cache using the user login retrieved from the authentication cookie as the key with a sliding expiration (let's say something like 30 min or make it equal to the authentication session), if the user visits another page within this period (ie. before the data is removed from the cache), I get the data from the cache and all is ok, but if I can't find the data in the cache (ie, returns null) then I update the last login in the database and get the user data again from the database and cache it in ASP.NET's cache. What do you think about this solution? Do you have any better ideas? I know I could use sessions but I read somewhere that if you handle the session_start event the session is created anyway even if you don't have and data in the session which is not really a good idea (this mean that a session object will be created for all site users authenticated or not).
- what about security? Assume my encryption was broken by some hacker, can't the hacker insert a different user login in a ticket and encrypt it with my broken encryption key? In my application I'm using the user email address as the user login, so, probably a hacker can insert a random email address (from an email list for example) in the ticket and try to access the account of that user, if the user happens to have an account on the site, this will work. My question is that, is the cookie encryption the only way for protection? Because I believe it still can be broken no matter how good it is and in this case it can be a disaster as described above. I'm thinking about something to prevent this, I might probably add something like a random code in the users table in my database (let's call it a security code) and include that code along with the user login in the authentication ticket (separate it from the user login by some character like a pipe for example or put it in the userdata section in the authentication ticket) and whenever we get the data of this user from the users table, we check for the security code along with the user login, for example:
select userid, {other fields here} from users where userlogin = {user email retrieved from the authentication ticket} and SecurityCode = {security code retrieved from the authentication ticket}
Do you think this can be reliable?
Beside the questions above, if you have any resources on the internals of ASP.NET forms authentication, I'd be very grateful if you shared them with me. I've been searching the net for a couple of days but all I can find so far is only about how to use ASP.NET forms authentication in your applications e.g. how to configure it in web.config .. etc but nothing about its internals. I also tried to use .NET Reflector (specifically to disassemble FormsAuthenticationModule) and gained some understanding about how it works internally but not enough to figure it all out.
Sorry for my really long post!
Your help is really much appreciated ...
modified on Thursday, May 22, 2008 7:08 PM
|
|
|
|
|
I have seen people using this and I don't understand why or what is the main purpose.
is it just to hide some implementations details to define such a new class (XXXimpl) and that the main one only servs to provide access to the interface functions ?
Thank you in advance.
|
|
|
|
|
I would suspect that what you are looking at is a case of having an abstract base class and a concrete implementation class. This is one of the most over abused uses of OO you can find. Basically what happens here is somebody creates a base class for something that they are only going to do once and then creates a concrete implementation of it. For some reason, they think this is going to aid them in reuse.
|
|
|
|
|
Pete O'Hanlon wrote: For some reason, they think this is going to aid them in reuse.
You mean it doesn't?!
I'm not sure I'd go so far as to say that, but I would certainly say it's the result of people learning "just enough" about the OO concepts to be dangerous. Without actually understanding what the benefits are and both why and when to use them, people are destined to make mistakes and abuse the pattern.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
Pete O'Hanlon wrote: For some reason, they think this is going to aid them in reuse.
Probably the reason for this is because it does.
Steve
|
|
|
|
|
thank you all for your precious interventions.
indeed the recent example I found and which prompted me to post a question here was the MFC feature Pack. OK the source code is not written by Microsoft, but there was the new FrameWnd class along with another FrameImpl class, in separate files.
the frame class holds an object of the Impl type,( and visversa I the Impl object holds a pointer to its corresponding Frame window object): at least for example you can notice the following :
BOOL IsMenuBarAvailable () const
{
return m_Impl.GetMenuBar () != NULL;
}
this is a member function of the FrameWnd.
not all members are encapsulated like this, and also some memebers are public visavis the consumer of the FrameWnd class.
|
|
|
|
|
Stephen Hewitt wrote: Probably the reason for this is because it does.
You what? Why does separating a class out into an abstract and concrete implementation aid reuse? Read what I said and you'll find I'm talking about somebody splitting a class up into an abstract/concrete implementation where there is no need because it's never going to be reused. Sorry but there you go - reuse only applies if you have proper design.
|
|
|
|
|
Pete O'Hanlon wrote: Read what I said and you'll find I'm talking about somebody splitting a class up into an abstract/concrete implementation where there is no need because it's never going to be reused. Sorry but there you go - reuse only applies if you have proper design.
Yes but to be fair, you are making an assumption about the OP where there is no information suggesting this has occurred because, well there is no information at all about the project in the OP.
led mike
|
|
|
|
|
led mike wrote: Yes but to be fair, you are making an assumption about the OP where there is no information suggesting this has occurred because, well there is no information at all about the project in the OP.
Actually, I was making a generalisation. Let's not get our assumptions confused with our generalisations - that way madness lies.
|
|
|
|
|
Pete O'Hanlon wrote: Actually, I was making a generalisation
I won't argue since trying to re-read it while looking for the distinction is making me dizzy
Pete O'Hanlon wrote: I would suspect that what you are looking at is a case of
led mike
|
|
|
|
|
Yep, its a sister pattern to the far too common Foo/IFoo pairing.
|
|
|
|