473,394 Members | 1,703 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,394 software developers and data experts.

Where should function reside?

9
In my application I have 3 classes.

1. class A
2. class B
3. class C

Application controller (having main function) has the object of class A, class A has object of class B and class B has objects of class C.

Application Flow:
1. Application reads some inputs.
2. Application does some calculations.
3. Stores generated data into excel file.

My question is:
Functionality of setting of data members of the class should be in main function or in their respective parent classes?

Means: function which sets data members of class C , should reside in Class B or it should be in class "Application controller"?
Feb 14 '08 #1
5 1533
r035198x
13,262 8TB
In my application I have 3 classes.

1. class A
2. class B
3. class C

Application controller (having main function) has the object of class A, class A has object of class B and class B has objects of class C.

Application Flow:
1. Application reads some inputs.
2. Application does some calculations.
3. Stores generated data into excel file.

My question is:
Functionality of setting of data members of the class should be in main function or in their respective parent classes?

Means: function which sets data members of class C , should reside in Class B or it should be in class "Application controller"?
What do classes A, B and C do? You don't write down class names before you decide what the classes are supposed to do. Rather the application logic decides which classes are needed. The methods are simply actions which objects(created from your classes) can perform. So as an example(a lame one) if you decide that you need an Input class, the action readInput would obviously be a method in the Input class.
Feb 14 '08 #2
hirak1984
316 100+
In my application I have 3 classes.

1. class A
2. class B
3. class C

Application controller (having main function) has the object of class A, class A has object of class B and class B has objects of class C.

Application Flow:
1. Application reads some inputs.
2. Application does some calculations.
3. Stores generated data into excel file.

My question is:
Functionality of setting of data members of the class should be in main function or in their respective parent classes?

Means: function which sets data members of class C , should reside in Class B or it should be in class "Application controller"?
according to my understanding of your problem,
neither should the business logic stay in the "main", nor in the classes (A,B,C whatever).
it should stay in some private method, which the main will call to execute the job.
but please post details of your application, for better understanding.
Feb 14 '08 #3
Anane
9
according to my understanding of your problem,
neither should the business logic stay in the "main", nor in the classes (A,B,C whatever).
it should stay in some private method, which the main will call to execute the job.
but please post details of your application, for better understanding.


Detailed explanation:
take example of vehicle engine: Engine(class A) has cylinders(Class B). Cylinder has pistons(Class C). each class have got their own data members.
Like for class A :1. engine no. 2. engine material 3. engine size. etc
Class B : 1. cylinder diameter 2. cylinder thicknes 3. cylinder height
Class C : 1. piston diameter. 2. piston material 3. piston thickness

my question is : function assigning values to data members should reside where? in "application controller class" or in respective classes that is function which set data menbers of class piston should reside in class "Class piston" ?
Feb 15 '08 #4
r035198x
13,262 8TB
Detailed explanation:
take example of vehicle engine: Engine(class A) has cylinders(Class B). Cylinder has pistons(Class C). each class have got their own data members.
Like for class A :1. engine no. 2. engine material 3. engine size. etc
Class B : 1. cylinder diameter 2. cylinder thicknes 3. cylinder height
Class C : 1. piston diameter. 2. piston material 3. piston thickness

my question is : function assigning values to data members should reside where? in "application controller class" or in respective classes that is function which set data menbers of class piston should reside in class "Class piston" ?
Normally you have them in the class whose members they are setting.
Feb 15 '08 #5
hirak1984
316 100+

my question is : function assigning values to data members should reside where? in "application controller class" or in respective classes that is function which set data menbers of class piston should reside in class "Class piston" ?
Normally the set data members of class piston should reside in class piston.
and u will call the set...() of the piston class from your main to set the values.
hope that is clear.
god bless
Feb 15 '08 #6

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

Similar topics

17
by: Jonas Rundberg | last post by:
Hi I just started with c++ and I'm a little bit confused where stuff go... Assume we have a class: class test { private: int arr; };
6
by: Marcus | last post by:
Hello all, This is baffling me. I am starting a session and I know it is setting a cookie on my computer - I called getallheaders() and see that it is setting the cookie, and it is also...
1
by: Harald Armin Massa | last post by:
Hello, I am using ZODB "standalone" in version 3.3.1 within some application. Now I learn that the 3.3.x branch of ZODB is "retired". No problem so far, everything is running fine. BUT......
5
by: tkk | last post by:
Hi All, Is it possible to load a function at a particular address/memory through the source program specification itself (or) is it upto linker/loader combination which decides this? For ex:...
2
by: Sean | last post by:
Hi all, I know that some variables are stored on heaps and some on stack in C++. How about functions? where does function reside on memory? Is it stack or heap? And are both function (not...
7
by: Random | last post by:
I have created a couple of DLL's in .NET that I want to use in a couple of my web projects, that will be running on the same web server. Instead of thn using the'bin' directory, what is the...
3
by: Richard Lewis Haggard | last post by:
I have a test application that is calling an assembly that reads some strings out of a config file. Normally, this assembly supports a web application and the information can be read just fine....
7
by: puzzlecracker | last post by:
Dynamically allocated objects reside on a heap, local objects on a stack. What about static objects? Thanks
1
by: =?Utf-8?B?VGVycnk=?= | last post by:
I am using the My.Settings object to save user settings. During testing, I want to 'zero' out what has been saved to start with the defaults again. Where doies the framwork actually persist these...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.