we need recursion to model things that are inherently recursive, such as a hierarchical file system, where each folder (including the root) can contain files and folders.
Luc Pattyn [Forum Guidelines][My Articles] The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
Any recursive algorithm can be implemented using non-recursive code if one maintains one's own stack to hold intermediate results. In many cases, however, recursive code can be more efficient and readable. For example, if one has a tree structure which represents an expression (each either holds a value, or else an operation and up to two operands which will yield a value) one may very easily define something like (ignoring the constructor and various other things):
Dim LeftOp, RightOp as OpNode
Function Eval asDouble
Return LeftOp.Eval + RightOp.Eval
While there would be ways to handle such things non-recursively, they would be decidedly awkward. Recursion allows things to be handled very smoothly. If one would be worried about stack overflow, one could do something like:
Dim LeftOp, RightOp as OpNode
Function Eval(MaxDepth as Integer) asDouble
If MaxDepth < 0 then Throw New WhateverException("Expression too complicated")
Return LeftOp.Eval(MaxDepth-1) + RightOp.Eval(MaxDepth-1)
Still much nicer than maintaining a "to-do list" manually.
There are many more situation where recursion is needed.
It makes sense each time you can solve a problem by applying the same methods on its bits.
One of the typical example is a function that copy a folder somewhere else.
If you were to program it without recursion you would have to write:
for each file in folder
for each subfolder in folder
for each file in subfolder
for each subsubfolder in subfolder
for each file in subsubfolder
... what if there is some subsubsubfolders?
Using a recursive algorithm you would have less code
for each file in folder
for each subfolder in folder
copyfolder(subfolder) ... this line iswhere the recursion happen
Seen in CodeProject forums :
Is it a sort of male dominance thing? You know, who can be the most witty? Who considers themselves the clown at the party?
Is it a follow the leader thing? One can't be seen not to have an elaborate signature, it's just no right, after all, all the other people have one.
(Is that long enough?)
There isn't a de facto app for testing. You can use ANY product that records keystrokes/mouse-events and plays them back for blackbox-testing. For white-box testing, I'd recommend the Visual Studio debugger.
It was a decision taken in the original design on C#. Multiple inheritance is deemed to complex, without enough benefits.
Inheritance is often described as an "is-a" relationship. I.e. a Car is-a vehicle so the car class inherits from vehicle. Usually, when people try and do things with multiple inheritance, what they are doing is forming a "has-a" relationship, which would be better represented as a class that contains the other class, rather than inherits from it. There aren't many cases where you have an object that is two separate types of sub objects. A Car is-a vehicle and a car also is-a ManMadeItem, but this forms a hierarchy (Car->Vehicle-ManMadeItem) so multiple inheritance isn't needed. If you look at your design, I think you'll find in almost all cases where you have multiple inheritance you can either change it to a hierarchy or a composition instead.
Even in languages that support it, it is general discouraged.
A Car is-a vehicle and a car also is-a ManMadeItem, but this forms a hierarchy (Car->Vehicle-ManMadeItem) so multiple inheritance isn't needed
I don't think I'd regard that as a hierarchy, because a horse could also be regarded as a Vehicle even though it is not a ManMadeItem.
I think the simplest way to look at the issues of inheritance versus interface is that an inherited base class can supply default fields and methods which are then usable by child classes; an interface not only does not provide default storage for fields and code for methods, but it can't even bind them by default. If an object inherited from Class1 and Class2, both of which provided a Smile method, it would be unclear whether TheObject.Smile was supposed invoke Class1.Smile or Class2.Smile. With interfaces, however, there is no problem. TheObject must have an "implements" line for every interface method it supports, indicating what method should be used for Interface1.Smile and which one should be used for Interface2.Smile. Further, to actually use either of those methods on an object, the object must first be cast to Interface1 or Interface2. Thus, there is no ambiguity.
I'm really hoping for an easy answer to this issue. I have a client device that uses a hardwired connection to communicate with its server if it is in a docking station. If lifted from the docking station the hardwired connection is disabled and it switches to its wireless connection. This is where remoting stops working on the serverside.
The client device has 2 network cards with different IPs, one for the hardwired connection and one for the wireless connection. When switching to wireless/hardwired the client is still able to send messages to the server, but apparently the server is still trying to reach the client on the connection it initially used so the return messages fail.
How is this fixed? Where is this fixed? I've tried to call RemotingServices.Configure again but it seems you can only call that once. Unregistering and re-Registering channels doesn't seem to work either. Any ideas would be greatly appreciated! Solutions even more!
I seemed to have fixed the problem (not sure how I did it, and I hope I can do it again in the future!) But I have another problem. When I run the setup app, I get the Application Install dialog, and it gives the name. I would like to change this name since somehow the name has a date associated with it (and the date has since changed.) I did a search throughout the whole project for the date, and could nto find it. Perhaps it is in the registry somehow?
I've spent the last couple of hours looking into a pretty big topic and I don't really feel like I've made any progress on the topic. I'm getting emails from potential users of my application concerned/worried/annoyed about the fact that my app may require a massive download for offline installation (a common scenario for my users).
My app targets XP SP2+ users on 32/64 bit OSes. My app is a .NET 3.5 SP1 based WPF product.
My installer already checks for 3.5 SP1 and contains the dotnetfx35setup.exe that will only download the required bits if the required framework version isn't installed. So for online users the problem isn't massive. However, I would like to make a single self-sufficient install .exe file that can take care of all users rather than pointing offline users to a 200mb+ installer on the Microsoft site.
I've been looking through the myriad files that make up the main dotnetfx35.exe and from what I can gather there isn't actually much I can strip out. Has anyone got any links of info on what can be done?
Considering that I'm including XP/Vista and 32/64 bit I still need to carry .NET2.0 / .NET3.0 / .NET3.5 stuff which is arguably nearly all of it!! Feels like I'm stuck with the massive download situation ...
Not to mention the worry of trashing a users .NET install altogether. Any info or pointers would be really appreciated.
I've not played with the Client Profile, so I can't give any pointers there, but I do have another potential option for you. If your users have a worry on this, you could create two types of installs. One that has links to the redistributables, and the other that is merged together using ILMerge[^]. The ILMerge version would be a lot bigger than the other version, but it won't contain the whole framework, only the bits you need.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.