|
OK, thanks. But if I put them in the parent class then the 3rd child class will also get access to these attributes which it doesn't need.
For example, I have 3 child classes: Contact, Organisation and Facility, which inherit from a parent class. Contact and Organisation have a credit limit attribute but Facility does not. Is it bad practise to put the credit Limit attribute in the parent class, giving the Facility class access to it?
|
|
|
|
|
Yes it is. Often enough in these cases, there is no free lunch.
|
|
|
|
|
One thing you could do it create the base class and build the interface as protected.
While doing it this way does force you to fully inherit from the base class even to get its full implementation public, it allows inheritors to decide what inherited attributes are publicly exposed, giving you a bit of control with regards to what attributes are propagated outwards to the public interface of the inherited classes.
It is a bit of a hack but one I have used successfully before.
|
|
|
|
|
Hi,
inheritance is not limited to two levels. You could do (pseudo-code):
class A
class B inherits from A
class C inherits from B
class C1 inherits from C
class C2 inherits from C
so B, C1, and C2 share everything in A
C1 and C2 share everything in C, but B does not.
|
|
|
|
|
Thanks. I had considered this but thought it to be a little over elaborate for the sake of about 3 attributes/properties. So was wondering if there were any other ways around it. I think this is the way I'm going to go though.
Thanks for the advice all
|
|
|
|
|
you're welcome.
|
|
|
|
|
I cant able to delete a subfolder inside a folder.
What i going is, opening a file from subfolder, reading it and closing the file and copying it to other folder and then deleting that file. Same i doing for all files in that subfolder. then checking that subfolder size if its size is zero, deleting it.. this is the code i used to delete the folder
path = "c:\newfolder"
For Each fld In path.SubFolders
If fld.Size = 0 Then
fld.Delete : here i am getting permission denied, error 70
End If
Next fld
I am closing all the FileSystemObjects.
jishith
|
|
|
|
|
Is this in Vista? Run the file as an administrator?
|
|
|
|
|
Hi,
there could be several reasons why a folder cannot be deleted:
- it contains some files; checking its size against zero is not correct, what if there is an empty file?
- the file you tried to delete in an attempt to empty the folder did not get deleted for one of many reasons
- the folder is in use, e.g. there is a Windows Explorer window open showing it.
- the folder was created by some one else, you don't have delete rights for it.
|
|
|
|
|
Hi,
Thanks for replying. but..
1) Checking the file folder size with 0 is not correct, here the folder is empty
2) I manually creating the folder, so no right issues
3) I can delete that folder, whn i am running my application for the next time. Only the first instance its showing permission denied. First i thought some oject is not releasing. But i making all the object i used in the function to nothing. Still it showing permission denied.
If there are four folders, its deleting three folders and when its come to the last one, the permission is denied.
How i make sure the folder is not in use? Or how to release the in use folder?
Jishith
|
|
|
|
|
Perhaps you are the one who has the folder in use? Can a reference to fld keep the folder "locked for editing"?
Second question;
For Each fld In path.SubFolders
If fld.Size = 0 Then
fld.Delete <code>- Is this allowed in a foreach?</code>
End If
Next fld
I are troll
|
|
|
|
|
Thanks eddy,
i resolved the error...
|
|
|
|
|
when i am compiling my vb6 project i am getting automation error. I looked it up in the google but did not find much help.
What is the reason for getting this error?
Please help me
Regards
|
|
|
|
|
|
Mustafa Ismail Mustafa wrote: What version of the .NET framework are you using?
he is using vb6 so no .NET framework at all
|
|
|
|
|
If its calling managed code, and its faulting, it'll raise that error.
|
|
|
|
|
Point taken, I shall be more careful next time
|
|
|
|
|
No worries, I'm just glad you didn't ask what I had to go through to find out.
The horrors.
|
|
|
|
|
lol.
Jon-boy writes note down for future reference...
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Learn from others my friend. I got gray hairs working on that project. :shudder:
|
|
|
|
|
I know the feeling have one off those project's under my care as well. Written by a former employee, hasn't given me gray hairs (yet) but at my age it would have to be a very horrifying project to do that
Did learn a lot from it tho, mostly how not to do something but that's a start (I guess).
|
|
|
|
|
I turn 29 on the 12th of February, need I say more?
|
|
|
|
|
Ok it has to be very very bad then
(I just turned 25 so...)
|
|
|
|
|
|
If you'r using the standard windows controls you'll have to create the form from scratch and do all the painting yourself (not easy and very time consuming).
This could also be a windows theme the user installed, in that case you don't have any control over it.
If you are using components there is a chance they support skinning but you would have to look at there site for that.
|
|
|
|