|
OO was never about performance. It was about finding a better way to model a problem domain so that it would be easier to maintain a codebase.
Whether or not it succeeded at this is very dependent on the skills of the original designer and how well the OO model actually fit the problem domain.
|
|
|
|
|
obermd wrote: Whether or not it succeeded at this is very dependent on the skills of the original designer and how well the OO model actually fit the problem domain Excellent answer, and very much on point. OOP is not a magic bullet, just like functional programming and other models aren't. They are tools, useful in some cases and problematic in others.
Software Zen: delete this;
|
|
|
|
|
C++ is NOT OO
not OO
not OO
what you're seeing is generic programming.
You need the book Accelerated C++ by Andrew Koenig and Barbara Moo.
Best $15-$20 USD you will ever spend.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
|
it's sort(v.begin(), v.end())
but this does allow you to sort a range within the container.
|
|
|
|
|
Because even though OO design was considered the norm for C++, it still had clearly defined use cases, and STL algorithms were never considered one of them.
I could get theoretical about it, but just stating the practical difference is easier:
- OO design is for helping humans to deal with abstract concepts.
- Functional design is for writing fast algorithms with low coupling.
Basically, STL containers are OO because it makes sense to modify, expand and build on top of them.
STL algorithms are functional, because they perform time-critical individual tasks and you're not encouraged to mess with them.
All in all, it's proper design, because you shouldn't use OO design for algorithms.
|
|
|
|
|
Very good answer, thank you!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
It's just a different abstraction where the iterator idea forms the interface. I find it far easier to work with than c# and linq tbh
|
|
|
|
|
When an object model you didn't design with caching in mind can implement intelligent caching with very little code changes.
I backed all my objects with normalized json - basically an object is represented by a Dictionary and an array is represented by a List
each property already did localized caching for individual fiels
public string Title
{
get {
return GetCachedProperty("title",(string)null);
}
}
and has a public Json property that contains the root for that object.
All I do is create a larger Json object and root each object in that. When an instance is created, the first thing it does is root itself in the larger cache document. Like so
void _InitializeCache()
{
var networks = Tmdb.GetProperty("networks", (IDictionary<string, object>)null);
if (null == networks)
{
networks = new JsonObject();
Tmdb.Cache.Add("networks", networks);
}
object o;
if (networks.TryGetValue(Id.ToString(), out o))
{
var oj = Json;
var d = o as IDictionary<string, object>;
if (null != d)
{
JsonObject.MergeReplace(oj, d);
Json = d;
}
}
else
networks.Add(Id.ToString(), Json);
}
Since the Json graph is all objects, it keeps references intact so you can reference the same branch from multiple places and there will only be one copy, even though if you serialize the JSON out each reference will be written out (so N copies)
Anyway, what's cool is you can check the cache simply by calling
Console.WriteLine(Tmdb.Cache); // basically an IDictionary object with an overloaded ToString method.
or clear it by calling Tmdb.Cache.Clear();
or traverse it as lists and dictionaries.
And it can easily be serialized and deserialized (as long as your cross references don't hose it too badly)
It's pretty cool overall.
I just designed it to back The Movie Database's JSON/REST api but in doing so I made the caching completely automatic without even changing much of my code.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
|
I'm sure his funeral will be well attended - remember, "where there's a Will, there's a bunch of vultures".
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
But those aren't friends are they?
|
|
|
|
|
They were when they thought he might give them something!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Ah, but those aren't Friends, they are "friends".
|
|
|
|
|
There's a difference with Farcebok?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm pretty sure he'll be disassembled.
Some parts might still be usable
|
|
|
|
|
"Asps. Very dangerous. You go first."
Software Zen: delete this;
|
|
|
|
|
|
|
I just downloaded Adobe Acrobat Reader.
After it installed it took me to a page with "Here is another product that might interest you..."
Except the rest of the page is blank.
That's right, Adobe, I'm not interested in anything else you have to offer!
|
|
|
|
|
|
Get FoxIt, free, fast and somewhat ad free.
Technician
1. A person that fixes stuff you can't.
2. One who does precision guesswork based on unreliable data provided by those of questionable knowledge.
JaxCoder.com
|
|
|
|
|
Hardly. I've found it to get more and more bloated as time went on, and you have to use the Custom Install feature otherwise it'll drag in extra crap you don't want/need. I've finally given up on FoxIt when they kept insisting on installing, and re-enabling, that Facebook plugin every time I downloaded an update. Why a PDF reader needs a Facebook plugin, I'll never know.
Personally I've been using Sumatra. I'm not sure if it's abandonware, as it hasn't been updated in years, but the lack of constant upgrade nag is a nice change of pace. I've yet to encounter a PDF that it couldn't read and render properly.
|
|
|
|
|
Whenever I've tried Adobe reader o found it slow and bloated. That's why I went to FoxIt.
Technician
1. A person that fixes stuff you can't.
2. One who does precision guesswork based on unreliable data provided by those of questionable knowledge.
JaxCoder.com
|
|
|
|
|
Everything's relative. But yeah, I'm pretty sure Adobe tops the list.
|
|
|
|