|
lclarsen wrote: The parent class is handy for sorting operations and other generic tasks, but I will need to differentiate between the instances at some point in my code. Should I have a type attribute in the parent class to tell me what attributes to read for a specific instance? I don't wan't to have virtual members in my parent class that are only meaningful for some instances.
The code should be using helper-methods from the object, and not refer to specific properties directly.
Take the <a href="http://msdn.microsoft.com/en-us/library/system.icomparable.aspx">IComparable</a>[<a href="http://msdn.microsoft.com/en-us/library/system.icomparable.aspx" target="_blank" title="New Window">^</a>] interface; it's the object's that tell the Sort method how to compare the items in order to sort them.
Bastard Programmer from Hell
|
|
|
|
|
lclarsen wrote: don't wan't to have virtual members in my parent class that are only meaningful for some instances.
I understand your concern here, but it reminds me of a cooking expression. If you are going to make an omelet, you have to break some eggs. Yes the parent will need to implement a 'default' implementation for each, but that is just the nature of the beast.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
That's where we separate concerns using interfaces. It's not required for the base to implement all members, we can implement interfaces at a higher level. That way we don't force a specific set of members up the inheritance-chain, and still have the luxury of interacting with a part of the inheritance-set using a common interface .
Bastard Programmer from Hell
|
|
|
|
|
Chris,
I guess I was hoping you could offer some powdered eggs or something, so I wouldn't have to break any
Anyway - the conclusion seems to be there isn't really any perfect solution to this. I somehow suspected that. Thanks for the input everyone
|
|
|
|
|
You can use interfaces to get around the problem. Each of the child classes implements an interface that it needs to support. And then you can use code like this to check if you need to call some method on the child items.
ItemBase item = listControl.Items[x];
if (item is IFileItem) {
IFileItem fileItem = item as IFileItem;
fileItem.Save();
}
|
|
|
|
|
lclarsen wrote: I'm in the process of defining some classes for the elements in a type of listbox control.
This is a display problem.
lclarsen wrote: The parent class is handy for sorting operations and other generic tasks, but I will need to differentiate between the instances at some point in my code.
This looks like it isn't a display problem.
So two possibilities exist.
1. The logic really has nothing to do with the display problem. So what is the problem?
2. The logic is about display. Then it is simple, don't mix display logic and business logic.
|
|
|
|
|
The question I always ask myself to find out what kind of relationship two objects really have, is whether it's a 'is a' or 'has a' relationship. E. g. a Mercedes 'is a' car, so it inherits all methods and properties of a generic car. And it 'has a' three-pointed star. You wouldn't inherit a 'Mercedes' from a three-pointed star, would you?
Your case sounds more like a 'has a' relation ship, in that all the other classes 'have' an ID, title, etc.. The obvious way would be to just let every class have these members, but if all classes are going to have the same 3 or 4 member variables, then chances are these belong together in a class of it's own. or maybe just a struct:
struct ID {
int id;
std::string title;
};
class MyDialog {
ID id;
};
class MyButton {
ID id;
};
Now you need to decide if that is sufficient for the operations you want for these classes. You will get a bit of redundance this way: e. g. accessors for each class that uses ID. But I see no reason to have virtual methods or inheritance.
|
|
|
|
|
sexy girlï¼video for adult ï¼ more than 30 videos.http://sharecash.org/download.php?file=2531204
|
|
|
|
|
Hi,
I have a conflict while designing a tree, with each child has the option of getting deleted individually.
I have designed a tree view with say some 5 children to it, each having the option of getting deleted. At the same time for the whole tree view, I have the option of Saving the changes performed to the tree and Reset them to previous state.
I need a suggestion, is it wise to restore a deleted child, during the RESET of the tree view? I can foresee a design flaw in this.
Thanks
Ambe
|
|
|
|
|
I rarely have to support UnDo/Restore/Oops functionality as it has very limited use in LOB work. I usually take a copy of the data before loading the tree, if the user wants to cancel changes simply reload the tree from the copy. I do not allow them to undo past a save so after a save I update the copy with the current data.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I total agree with this method. That is how I do it. Makes the logic a lot easier and usually makes the user happy.
|
|
|
|
|
Ambe wrote: I have designed a tree view with say some 5 children to it, each having the option of getting deleted. At the same time for the whole tree view, I have the option of Saving the changes performed to the tree and Reset them to previous state.
I need a suggestion, is it wise to restore a deleted child, during the RESET of the tree view? I can foresee a design flaw in this.
Not during the reset, but after. I'm usually copying the complete internal state into a Memento-pattern, simply restore from there when required. Yes, users can undo after they saved, marking the document dirty again.
Bastard Programmer from Hell
|
|
|
|
|
Hello all,
I have been assigned a task to work with few in-house developers in developing our internal Employee Portal which include, Time Tracker System, HR Portal, Performance Tracker and Asset management System, All deployed on one Windows Small Business Server.
The requirements gathering and documentation is almost done and we are about to start working on core development.
However, as I lack a project level knowledge while developing web applications. Can I get help on what best practices should I be implementing even from the database design stage?
The application is intended to be interacted by close to 200 people and half of them concurrently, at times. Most of the data tables are expected to be use by different modules of the same application.
Any help with guidelines to be followed while designing the database and application layers, will be greatly appreciated.
You can send me an email sunilsasadm@gmail.com
Thank you
|
|
|
|
|
First off I would look for an existing package and see if it meets your requirements.
If between you and Sunil Kokkiligadda wrote: few in-house developers you do not have any architecture skills I suggest getting in a consultant to do the initial work for you, at least the data structures. You are not going to be able to build such an application from forum support.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
My rates are pretty competitive if you need some professional help...
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
Can I have a detailed info on the services, in this context, that you can provide and your price?
You can send me a personal email.
|
|
|
|
|
I was being sarcastic.
BTW: you shouldn't put your email address in a post: you'll get spammed.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
tart
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
It doesn't take a Sherlock level of intelligence to jump on an opportunity like that. (useewhatididthar?)
I personally commend him!
Don't forget to rate my post if it helped!
"He has no enemies, but is intensely disliked by his friends."
"His mother should have thrown him away, and kept the stork."
"There's nothing wrong with you that reincarnation won't cure."
"He loves nature, in spite of what it did to him."
|
|
|
|
|
Hi sunil,
Back end plays major role in any application. So while you are developing the Employee Portal ,take help from the experts and start learning from it.
Hope you will be good DB Designer.
Regards,
Srinivas
|
|
|
|
|
I currently working on a project in MVC .net and I found my self asking how far is to far for separation of concerns? A little back history. The project I am working on is separated into business logic, data access, and business entity layers. It is a web app that is developed using the MVC pattern so it also has Controllers and Views. We are currently using our business entity objects as our model for this project. But now one of the developers I work with wants to implement view models that inherit from the business entities. 99.9% of the time the view model will just be an empty class that inherits from the business entities. I am against using adding another layer to the app and I want to find out what some other peoples opinions are.
|
|
|
|
|
He says it is easy to code generate and we may use it in the future so why not just do it. To me it add more complexity to the project when 99 percent of the time we won't need the view models. I would rather just create the view models when we need them. The reason he would like to inherit from the business entities is so we don't need to map a view model to a business entity. We could just pass the view model to the business logic directly.
|
|
|
|
|
GateKeeper22 wrote: 99.9% of the time the view model will just be an empty class that inherits from
the business entities.
Presumably there is real business functionality represented by that 00.1% rather than pie in sky whimsy by developer(s) about some nebulous thing occuring in the future.
If no then absolutely not.
If yes then what happens to the funtionality represented by that 00.1% if you don't implement another layer? It is impossible to do or just a bit awkward? If impossible then do it. If just awkward then stick to awkward because nothing is perfect and that is what comments are for.
|
|
|
|
|
On the .1% of the time I add a view model to handle the difference and have a mapper function to copy the data from the business entity to the view model. It has only happened once so I only have one view model. I do it when it is need and the other developer wants to make it a standard an do it all the time even if it isn't needed.
|
|
|
|
|
You don't re-arch a system based on extreme corner cases when work around exists.
There are many real reasons why one doesn't do that for non-trivial applications which a multiple person system always is. Some of the ones that come to mind.
1. It adds complexity which increases maintenance cost.
2. There is no way to eliminate all corner cases.
3. A corner case can document itself but a re-arch requires much more explanation (and back to 1.)
4. The cost of a re-arch is much higher than implementing the corner case.
|
|
|
|