473,387 Members | 3,820 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,387 software developers and data experts.

How to make a value visible to anywhere in my app?

Hi, I'm still getting my head around programming with classes and I'm confused about something.
A have a class member that's set when I create an object. But my application has several other classes that I want to be able to see the value of this member and the only way I can think of to do that is by passing the member value as a parameter for the other class function that I want to be able to see the value.

Is this the right way to do it? It doesn't look neat and if I have several values to be shared then my functions will start to have too many parameters.
Any advice?
Thanks a lot.
Nov 20 '06 #1
4 1358
willakawill
1,646 1GB
Hi, I'm still getting my head around programming with classes and I'm confused about something.
A have a class member that's set when I create an object. But my application has several other classes that I want to be able to see the value of this member and the only way I can think of to do that is by passing the member value as a parameter for the other class function that I want to be able to see the value.

Is this the right way to do it? It doesn't look neat and if I have several values to be shared then my functions will start to have too many parameters.
Any advice?
Thanks a lot.
Hi. There are some things that you can do to make the value of this class member available to the rest of your app. However...
When you design a class it is important to think through encapsulation. If your other classes require this value then it seems logical that you should merge the classes together as they share functionality.

The value can be stored in a global variable but that will still present the same problems in having to pass it to your other objects and it destroys encapsulation.
Nov 20 '06 #2
Hi. There are some things that you can do to make the value of this class member available to the rest of your app. However...
When you design a class it is important to think through encapsulation. If your other classes require this value then it seems logical that you should merge the classes together as they share functionality.

The value can be stored in a global variable but that will still present the same problems in having to pass it to your other objects and it destroys encapsulation.
That's what I thought. The value I want to share is a language attribute that will tell different procedures in my application to use "Bonjour" instead of "Hello", for example. So I created an object that stores all the terms in the language the user chose to use. All I want is for this object to be visible anywhere in my app. There's just too much funcitonality to merge in the same class I think.
Nov 20 '06 #3
albertw
267 100+
That's what I thought. The value I want to share is a language attribute that will tell different procedures in my application to use "Bonjour" instead of "Hello", for example. So I created an object that stores all the terms in the language the user chose to use. All I want is for this object to be visible anywhere in my app. There's just too much funcitonality to merge in the same class I think.
hi

have you tried a res-file wihin your project?

call data from there with
something like:
Form1.Sample.Caption = LoadResString(20 + Var)
Nov 21 '06 #4
willakawill
1,646 1GB
That's what I thought. The value I want to share is a language attribute that will tell different procedures in my application to use "Bonjour" instead of "Hello", for example. So I created an object that stores all the terms in the language the user chose to use. All I want is for this object to be visible anywhere in my app. There's just too much funcitonality to merge in the same class I think.
You will find plenty to read about this right here
Nov 21 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: PCB | last post by:
Hi all, Not sure if this is possible, but can I change the controls of a command button on a per record bases in a subform. In my case, I would like to make a command button visible only if...
15
by: John Blair | last post by:
Hi, Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist....
2
by: jason | last post by:
Pardon my ignorance on this. The below code works, except, when I edit a record and update the two drop downs take the first entry in the dropdownlist if not selected. I'd also like the dropdown to...
4
by: NH | last post by:
Hi, I just cannot get this to work. I want to make a cell editable in a datagrid only if the value of another cell is something specific. I am able to capture the value of the other cell via the...
11
by: Bill Nguyen | last post by:
I need to make a set of constants to be available for the whole application. Public const is confined to the form from which constants are declared. Is there a way to declare once and all forms can...
2
by: Jake Barnes | last post by:
Imagine I've this block of HTML: <p>Alex Schein Mailing List <input type="checkbox" name="newslettersToUse" value="133156"> (<a href="mcControlPanel.php"...
2
by: windsorben | last post by:
I'd like to have an image appear after the student answers each short answer question correctly. I can't seem to get it to work properly. See code below. Thanks! <html> <head>...
19
by: zzw8206262001 | last post by:
Hi,I find a way to make javescript more like c++ or pyhon There is the sample code: function Father(self) //every contructor may have "self" argument { self=self?self:this; ...
3
by: Bill | last post by:
I have a report with a text box named Discount. If this text box shows a value of 0, I do not want the text box to be visible. I have tried the following code, but it disables the control even...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.