Solved

Class keeping track of own members vs not.

Posted on 2009-07-10
7
216 Views
Last Modified: 2013-11-12
Hi,

My apologies - the topic title isn't exactly the best way to summarise this question, but I'm afraid it's the best I can come up with. What I'm curious about are the advantages and disadvantages to having a static class that allows the creation of members (stored within a static array/vector within the class) as to having a normal class that can be instantiated with whatever creating the object looking after the object?

Obviously one advantage is if the static class keeps track of its own members then there's no reason to pass members as there is with an instantiated class.

Thanks,
Uni
0
Comment
Question by:Unimatrix_001
  • 4
  • 3
7 Comments
 
LVL 12

Expert Comment

by:Let_Me_Be
ID: 24827855
Actually there are many, many ways of tracking class instances. This particular case?

Well, it might be good if you for example want to provide a C API for a C++ objective code. This approach would be very natural (accessing object instances using some sort of ID).

Its hard to say, you didn't even specify the language. It might be just used as a walk around some language restrictions of some kind.
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 24827881
Hi, I assumed that a design system like this may be language independent, as not, I'm looking from the POV of C++.
0
 
LVL 12

Expert Comment

by:Let_Me_Be
ID: 24827986
Such question are always very language specific. Language constructs, although similar, have very different implementations and implications in different languages.

OK, well, from the design point of view: if it fits, just use it.

From the effectiveness point of view? Well, that's a bit harder. If the objects are very small and for some reason you need to access them from the whole program (using stack is not sufficient), using a static array, or even a dynamically allocated array might prove faster.

But once again, its hard to say in general. In C++ specifically, if a correct language feature or construct is used wrongly, it might be have big speed impacts.
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 3

Author Comment

by:Unimatrix_001
ID: 24828009
Hm, so essentially you're saying I'd need a specific example for any useful sort of comment regarding performance,effectiveness, etc?

Thanks,
Uni
0
 
LVL 12

Accepted Solution

by:
Let_Me_Be earned 500 total points
ID: 24828061
In this case yes. The construct is actually very specific, so if you want to speak about performance you need to see it in some context.

Keep in mind, once again, this has nothing to do with design decisions (if it fits, use it) and in many cases good design decision can be a bigger performance gain then any optimization.
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 24828066
Ok, thank you. :)

Uni.
0
 
LVL 3

Author Closing Comment

by:Unimatrix_001
ID: 31602283
:)
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question