473,395 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Object design question

One of my classes generates an array of a custom objects. That array
is passed to a validation class, which sets each member of the array's
isValid property to true or false.

The array is then passed to two more classes for further processing in
a read-only manner.

As I see it, I can pass the array to each of the two classes and let
each of them inspect the isValid property, processing only those those
objects which are true.

Or, after the array is validated, I could create an arraylist and
populate it with only those objects which have the isValid property
set to true, passing the arraylist to the remaining two processes.

Any ideas on which approach might be better? I'm not clear about
encapsulation versus the increased execution time.

TIA
Nov 22 '05 #1
4 1019
Hi larzeb,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know whether to process on
the original object array or populate another array. If there is any
misunderstanding, please feel free to let me know.

I think you can pass the object array reference to the rest two methods and
process on them directly. I think recreating an array of valid object
really takes time. Also I don't think it will be better than processing on
the original array.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 22 '05 #2
larzeb wrote:
One of my classes generates an array of a custom objects. That array
is passed to a validation class, which sets each member of the array's
isValid property to true or false.

The array is then passed to two more classes for further processing in
a read-only manner.

As I see it, I can pass the array to each of the two classes and let
each of them inspect the isValid property, processing only those those
objects which are true.

Or, after the array is validated, I could create an arraylist and
populate it with only those objects which have the isValid property
set to true, passing the arraylist to the remaining two processes.

Any ideas on which approach might be better? I'm not clear about
encapsulation versus the increased execution time.

TIA


Without knowing more of your specific implementation, I would (at first
glance) recommended sticking with the arrays rather than creating
ArrayLists. You risk application performance because of (potential)
boxing/unboxing operations being performed on your custom objects in the
ArrayList.

Chris
Nov 22 '05 #3
You are making extensive use of the visitor pattern (see
http://www.dofactory.com/Patterns/PatternVisitor.aspx ). It is not clear,
from the minimal detail you've provided, if this is a wise choice.

From your description, however, there is no reason to recreate the array.
Using an .IsValid property seems perfectly reasonable.

HTH,
--- Nick

"larzeb" <la****@community.nospam> wrote in message
news:7r********************************@4ax.com...
One of my classes generates an array of a custom objects. That array
is passed to a validation class, which sets each member of the array's
isValid property to true or false.

The array is then passed to two more classes for further processing in
a read-only manner.

As I see it, I can pass the array to each of the two classes and let
each of them inspect the isValid property, processing only those those
objects which are true.

Or, after the array is validated, I could create an arraylist and
populate it with only those objects which have the isValid property
set to true, passing the arraylist to the remaining two processes.

Any ideas on which approach might be better? I'm not clear about
encapsulation versus the increased execution time.

TIA

Nov 22 '05 #4
Thanks for Chris's response.

Hi larzeb,

This is correct, since object arrays are "strong typed", which is more
efficient. While arraylist treat all the contents as objects.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ggg | last post by:
I'm looking for a complete project/application done with heavy use of of object-oriented programming & design. Preferably something well documented and/or commented so that I can pick it apart...
3
by: andy2O | last post by:
Hello comp.lang.py, Can you help me with ideas for the following (somewhat newbie) OO design question in Python? Note, I'm using psuedo-code, not actual Python for the examples! Background:...
6
by: blueblueblue2005 | last post by:
here is a friend function of Class Array, which has two private data member: int size, int *ptr // Array's public member function to return size int getSize() const { return size; } friend...
22
by: ypjofficial | last post by:
Is there any possibility of invoking the member functions of a class without creating an object (or even a pointer to ) of that class. eg. #include <iostream.h> class test { public: void...
4
by: Carl J. Van Arsdall | last post by:
It seems the more I come to learn about Python as a langauge and the way its used I've come across several discussions where people discuss how to do things using an OO model and then how to design...
17
by: Divick | last post by:
Hi, I am designing an API and the problem that I have is more of a design issue. In my API say I have a class A and B, as shown below class A{ public: void doSomethingWithB( B * b) { //do...
11
by: John A Grandy | last post by:
I'm in a vigorous debate at my work regarding objects assuming knowledge of the type their containing object. This debate pertains specifically to ASP.NET, but I have decided to post in the C#...
0
by: =?Utf-8?B?SmVhbi1GcmFuY29pcyBCcmV0b24=?= | last post by:
"siddharthkhare@hotmail.com" wrote: The context is important in this kind of design concern : I assume there's a lot of user and that application will evolve to add richer functionality. My...
3
by: H. S. Lahman | last post by:
Responding to siddharthkhare... Ignore Topmind and frebe. They are anti-OO P/R guys. Let's not confuse things with specific 3GL syntax. At the OOA/D level the model looks like: | 1
7
by: joproulx | last post by:
Hi, I was wondering if there was a way with Reflection to find dynamically if an object was referencing indirectly another object. A simple example would be: Object1 | --Object2 |
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.