Originally posted by Master
The fact is, you shouldn't instantiate new objects in code blocks. It just creates more work for the destructor. It's easier and more efficient to keep manipulating one object.
Like I said though, sometimes its necessary. Say for multi-threading and you want multiple downloaders going on at once, for example's sake lets say you use the WebClient, using one webclient in multiple threads causes an overload and would cancel out works done by other threads. If you make the program dynamic you cannot pre-define all the webclients (well you kind of can but lets say you can't) my example is falling awkwardly but, you don't even need to wait for the garbadge catcher, you can simply create new and then dispose when you're done with it at the end of the loop, or you can call the garbadge catcher to do so itself.
All im saying is sometimes it might be the easier solution though its a weird example that I used. q-q
Originally posted by Pichu
Right there is the definition of Object Oriented Programming.
---------- Post added at 07:00 PM ---------- Previous post was at 06:58 PM ----------
The code itself can be neat or clean; cleaner code is much easier to read than messy code. Also, there is a such thing as commenting your code so the person reading what you have done, or even yourself, can know what is going on from actual language.
A person who knows their code will have a lot easier time reading code than a person who does not.
Well, I learned almost everything I know from studying old sources but lets say I see
Excuse any syntax errors, I wrote this from scrap.
System.net.Webclient x = new System.net.Webclient();
String data = null;
data = x.DownloadString("https://google.com/text.txt");
I can easily break that down. First we declare a new webclient, then a new string, then we use our webclient to download strings and put them in our string.
Where as
String data = new System.Net.WebClient().DownloadString("https://google.com/text.txt");
We both understand this but, someone new probably would be slightly confused.
I'm not saying we need to dumb down code, but its just in my personal history I'd prefer to read it in the first method that I posted compared to the second one.
Originally posted by TheQuagmire
Or you could like have a faster computer and those seconds won't even be there. Giggity.
It'll still be there no matter how fast your computer.