473,791 Members | 2,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OO Design question

Hello All,

Please help validate this design problem

Assume that I have several entities in my project (eg Supplier,
Customer etc).
All of them save several common properties - name, address, city,
state, zipcode etc

I thought of making a base class - BusinessEntity (with all of the
above properties)
Then, create Supplier/Customer class which derives from BusinessEntity
& have their own specialized behaviour.

Is this approach valid ?

Also, can a class be made base class solely on the basis of common
data, that it can hold ?
In my example, there is no point repeating (name, address...) in
Supplier, Customer
Hence, I think of creating BusinessEntity with all the above properties
So, is it valid to have base class with only data & no behaviour
(methods) ?
I would love to hear arguments in favour/against of the above approach

Cheers
Kalpesh

Dec 20 '05
24 2019
KJ...With .NET 2.0 you can implement delegation using generics!

using System;
using System.Collecti ons.Generic;
using System.Text;

namespace GenericMI
{
// first we create the abstractions
public interface I1
{
void SayHello();
}
public interface I2
{
int GetValue();
}
public interface IProgram : I1, I2 { }

// second we write the concrete classes that implement the
abstractions
public class Implementation1 : I1
{
public void SayHello()
{
Console.WriteLi ne("Hello.");
}
}
public class Implementation2 : I2
{
private int i = 1;
public int GetValue()
{
return i;
}
}
// finally we write the wrapper class that contains
// the concrete classes
public class GenericMI<T1, T2> : IProgram where T1 : class, I1,
new()
where T2: class,I2, new()
{
private T1 pimplI1= new T1();
private T2 pimplI2 = new T2();
// we forward calls to the contained object
public void SayHello()
{
pimplI1.SayHell o();
}
public int GetValue()
{
return pimplI2.GetValu e();
}
}
class Program
{
static void Main(string[] args)
{
GenericMI<Imple mentation1,Impl ementation2> mi=
new GenericMI<Imple mentation1,Impl ementation2>();
mi.SayHello();
Console.WriteLi ne(mi.GetValue( ));
Console.ReadLin e();
}
}
}

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Dec 22 '05 #21
Hi Everyone,

Although the discussion digressed a little, I got to see different view
points

Bruce, I liked your design :)
John - I will be reading the open-closed principle

I think, it requires great amount of understanding of domain (context),
before designing classes. So, making something base class, based on
common data - MIGHT not be a good idea.

Also, if I make address as part of BusinessEntity, it is kind of a
closed design
However, good discussion helps see different perspective

Thank you everyone & happy x'mas
Kalpesh

Dec 22 '05 #22
Real Quick, paraphrased Open-Closed principle means "Open for
extensibility, closed for modifications" This means that if you need
to add functionality to a system you do it by writing new code and not
modifiy existing code. Making address part of BusinessEntity is the
opposite of what I'm talking about if there is different functionality
associated with address data.

Good Luck.

Dec 22 '05 #23
Thank you everyone for your views

Kalpesh

Dec 23 '05 #24
would u please show the Aggregation instead of inheritance in code.

you seem you have experiance doing it before which many coder and i am
one of them didnt encounter the need to do it yet.

would be very please to see any simple code explaining it

Thanks a lot

Sharing makes All the Difference

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Jan 16 '06 #25

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

Similar topics

3
1488
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: ----------- I need to represent a small variety of mathematical constructs symbolically using Python classes.
0
1926
by: James Walters | last post by:
Hello, DB novice checking in here with a basic design question. I have a table called 'nms_apps' which stores information about all of our applications which we have developed/maintained for our client. One column which I would like to use is called 'used_by', which would store information about which business sections (Financial Management Branch, Human Resources Branch, etc.) use a particular application. Often
0
1387
by: Krist | last post by:
Hi All, I have a database design question, pls give me some help.. I want to define tables for salesman's sales target commission . The commission could be given per EITHER sales amount of : Group of Products OR Group of Brand. e.g : the data example : For one salesman_A : product_1, product_2, product_3 etc.. => sales = $100 - $200 =>
1
3287
by: Krist | last post by:
Hi All, There is some additional info I forget on this same topic I just posted. I have a database design question, pls give me some help.. I want to define tables for salesman's sales target commission . The commission could be given per EITHER sales amount of : Group of Products OR Group of Brand. e.g : the data example : For one salesman_A : product_1, product_2, product_3 etc.. => sales = $100 - $200 =>
1
2054
by: dixp | last post by:
I'm new to writing multithreaded apps and I have a design question. I have a winforms app and a class which has a method that does processing which is time intensive. I want the user to be able to kick off the process and continue to work in the appliaction while getting progress updates and the ability to cancel. The method that seems easiest to me is this: The class exposes certain events for progress. Start, ProgressUpdate, and...
3
1873
by: reageer | last post by:
Hi all, I have a design question: I have a bunch of users (name, address, zip, etc.). They are assigned a card with a specific id. The only thing unique is this card id, or probably the combination of all other user fields. So it's seductive to use the card id as the primary key. This card allows access to certain places and all access is logged.
7
308
by: Steve Long | last post by:
Hello, I have a design question that I'm hoping someone can chime in on. (I still using VS 2003 .NET 1.1 as our company has not upgraded XP to sp2 yet. duh I know, I know) I have a class I wrote (CAppInit) that I use for application configuration. It behaves similarly to Configuration.AppSettings with some extra functionality. This class is in an assembly (AppConfiguration) with another class. I would now like to extend the functionality...
29
2231
by: Brad Pears | last post by:
Here is a simple OO design question... I have a Contract class. The user can either save an existing contract or they start off fresh with a blank contract, fill in the data and then save a "new" contract. I have a method in my contract class called "Save" which is called like this... dim oContract as new Contract
9
1672
by: fjm | last post by:
Hey everyone, I lost my internet connection for about 5 months and finally got it back. This is one of the first places I came back to. I have to say that I had a heck of a time finding it because of the name change and facelift. :) Anyway, good to be back. I have a question that may be more of a design question. If this post doesn't belong here, I appoligize in advance, feel free to move it. I need to create a form that will be...
2
2538
by: RoaringChicken | last post by:
Hi. Vista Ultimate Access 2007 I'm developing an inventory database and have question on design. The database stores collection details. One item in the collection, one record. The design question is about showing related items. For example: I have a typewriter Model 1 I have a manual for typewriter Model 1 I have a manual for typewriter Model 2 but no typewriter model 2. What I would like is that when the record for typewriter...
0
9515
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.