Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Class keeping track of own members vs not.

Posted on 2009-07-10
7
Medium Priority
?
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Six Sigma Control Plans
Progress

610 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