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

Where to put my code?

Hi all,

I have a very simple issue that I often come up against. I'm just wondering
what the common consensus is on dealing with it.

I have a Project class, that has amongst other properties, an int representing
a ProjectManager. The question is what should I do when I want more details
on the project manager?

I have a couple of options:

I could add extra properties to the Project class so that as well as offering
an id, I can also get the project managers name and email perhaps.

Or, I can take that I'd at runtime and submit another seperate query to get
details on the project manager.

The pro of adding extra properties is that it is much easier to do a common
operation and doesnt require another sql query to be executed because I'd
just get the projman's details when getting the Projects details.

The disadvantage of this is that it breaks encapsulation. Purists believe
that the project managers details should only be contained in a ProjectManager
object.

I'm sure you've all come accross this scenario so I'm just wondering what
everyone else does.

Many thanks to anyone who can advise.

Kindest Regards

tce

Nov 22 '05 #1
1 1082
Hi, tce,

If you're not familiar with it, check out Martin Fowler's "Refactoring:
Improving the Design of Existing Code", and his website
www.refactoring.com.

I think his answer would be: keep your code and your coding abilities
in such a state that it doesn't much matter where the code goes,
_initially_, then when you realize it's not where it belongs, move it,
safely (because you have comprehensive unit tests to assure that such
changes don't affect its behavior). And I guess my answer is the same.
Peace,
--Carl

Nov 22 '05 #2

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

Similar topics

5
by: Rachel Weeden | last post by:
I'm working on an ASP Web application, and am having syntax issues in a WHERE statement I'm trying to write that uses the CInt Function on a field. Basically, I want to select records using...
2
by: BoB Teijema | last post by:
Hi all, One of our companies is having problems with a query on a linked server. They have two servers, serverA and serverB. On serverA they have set up a linked server to serverB. Query:...
4
by: Barry Edmund Wright | last post by:
I would really appreciate your assistance. I am using Access 2000 to create a form that Lists Names and Addresses based on a number of selection criteria one of which is a combo box cboPCZip. All...
16
by: Dixie | last post by:
I have a problem using Dev Ashish's excellent module to concatenate the results of a field from several records into one record. I am using the code to concatenate certain awards onto a...
7
by: Mr. Mountain | last post by:
In the following code I simulate work being done on different threads by sleeping a couple methods for about 40 ms. However, some of these methods that should finish in about 40 -80 ms take as long...
10
by: Ray Stevens | last post by:
I am attempting to test a VeriSign account and the setup instructions stated that the certs file needed to go into the Windows\System32 folder. I am getting an error from the code-behind assebly...
7
by: Britney | last post by:
Original code: this.oleDbSelectCommand1.CommandText = "SELECT TOP 100 user_id, password, nick_name, sex, age, has_picture, city, state, " + "country FROM dbo.users WHERE (has_picture = ?) AND (sex...
0
NeoPa
by: NeoPa | last post by:
Background Whenever code is used there must be a way to differentiate the actual code (which should be interpreted directly) with literal strings which should be interpreted as data. Numbers don't...
41
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
0
NeoPa
by: NeoPa | last post by:
Intention : To prepare a WHERE clause for multiple field selection, but to ignore any fields where the selection criteria are not set. ONLY WORKS WITH TEXT FIELD SELECTIONS. Scenario : You have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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: 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...

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.