473,808 Members | 2,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Choosing the right way to design a class library

Hello! :^)

I am trying to implement a class library for dealing with time series.
I have to use time series with seasonable component and without it.
Also, time series can be stored in memory or in a database.
The problem is to make 4 following classes:
1. non-seasonable and storable in memory
2. seasonable and storable in memory
3. non-seasonable and storable in database
4. seasonable and storable in database
In C++ this problem could be solved by using multiple inheritance. But
I can't inherit class more than from one class in C# and, if I use
interfaces I must write the same implementation of abstract members
myself. For example, if I make an interface ISeasonable, I will need
to write the same code for in-memory and database-storable time
series.

Please, help me to implement my task in C# (if it is possible)

Thanx for attention
Nov 16 '05 #1
2 1759
The designers of C# regard MI as Evil. Although I agree with this
generally, I agree that mixins would be useful.

To solve your problem my tendency would be to separate the relevant parts of
the TimeSeries implementation into separate classes and store instances of
those in private fields of a single TimeSeries class based on how the object
is created, i.e. with a constructor like:

public TimeSeries(bool isSeasonable,Ti meSeriesStorage Type storageType) {

if (isSeasonable) {
this.myImplemen tation = new SeasonableTimeS eriesImplementa tion();
} else {
this.myImplemen tation = new NonSeasonableTi meSeriesImpleme ntation();
}

switch (storageType) {
case TimeSeriesStora geType.Memory:
this.myStorageL ogic = new MemoryTimeSerie sStorageImpleme ntation();
case TimeSeriesStora geType.Database :
this.myStorageL ogic = new DatabaseTimeSer iesStorageImple mentation();
default:
throw new NotImplementedE xception(String .Format("Time Series Storage
Type {0} is not implemented.",s torageType));
}

}

.... where TimeSeriesStora geType is an enum:

public enum TimeSeriesStora geType {Memory,Databas e}

Now your internal implementation for various methods would reference the
myImplementatio n or myStorageLogic reference at runtime to access the
appropriate implementation logic.

Probably there are other ways to do this, but that's my $0.02.

--Bob

"PepsiDrink er" <ea***********@ mail.ru> wrote in message
news:6a******** *************** ***@posting.goo gle.com...
Hello! :^)

I am trying to implement a class library for dealing with time series.
I have to use time series with seasonable component and without it.
Also, time series can be stored in memory or in a database.
The problem is to make 4 following classes:
1. non-seasonable and storable in memory
2. seasonable and storable in memory
3. non-seasonable and storable in database
4. seasonable and storable in database
In C++ this problem could be solved by using multiple inheritance. But
I can't inherit class more than from one class in C# and, if I use
interfaces I must write the same implementation of abstract members
myself. For example, if I make an interface ISeasonable, I will need
to write the same code for in-memory and database-storable time
series.

Please, help me to implement my task in C# (if it is possible)

Thanx for attention

Nov 16 '05 #2
Oh, thanx. That's an interesting idea.
Nov 16 '05 #3

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

Similar topics

0
1690
by: Carsten Gehling | last post by:
> -----Oprindelig meddelelse----- > Fra: python-list-admin@python.org > På vegne af David McNab > Sendt: 17. juli 2003 01:32 > Til: python-list@python.org > Emne: Re: Choosing the right framework > I've been working on an HTML generation framework called 'pyWeb'. Just > posted to this ng yesterday, calling for testers. >
42
4122
by: Fred Ma | last post by:
Hello, This is not a troll posting, and I've refrained from asking because I've seen similar threads get all nitter-nattery. But I really want to make a decision on how best to invest my time. I'm not interested on which language is better in *general*, just for my purpose. My area of research is in CAD algorithms, and I'm sensing the need to resort to something more expedient than C++, bash scripting, or sed scripting.
7
1646
by: Phi! | last post by:
Hello everyone, any help with this would be appreciated as I have spent the past afternoon trying to sort it out. I have two questions based on the followiung information. I have two classes: - Class A { Method 1() {}
2
1093
by: shesh | last post by:
Hi All, I need your advice, since I'm a programmer of windows forms for some times, but never had any real experience in web applications. I need to design a new system for web purposes, but I don't know which technology and/or design pattern is the best for me. I need to design a web site, which can process a large amount of user's simultaneously. The purpose of the site is to give real time quotes and statistics data
0
1757
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. In this user control we have a class called B One project that build a class library dll. In this class library we have a class called C In the user control project I have a project reference to the class library.
4
1271
by: Steve Y. | last post by:
Hi, I need some input to help my thinking process. We have a multi layer web application now but we didn't do a very good job separating the business logic from the user interface logic. So as you can imagine as it is getting bigger it is harder to maintain. We would really like to pull the business logic into class objects but I am stuck on the concept. Today the web front end reacts to events and makes web service calls. The web...
25
2153
by: David Sanders | last post by:
Hi, As part of a simulation program, I have several different model classes, ModelAA, ModelBB, etc., which are all derived from the class BasicModel by inheritance. model to use, for example if the parameter model_name is "aa", then choose ModelAA. Currently I do this as follows:
38
2683
by: ifti_crazy | last post by:
I am VB6 programmer and wants to start new programming language but i am unable to deciced. i have read about Python, Ruby and Visual C++. but i want to go through with GUI based programming language like VB.net so will you please guide me which GUI based language has worth with complete OOPS Characteristics will wait for the answer
14
1592
by: Leah | last post by:
I am a student and are required to build a website that provide services (client-server). I need advice in choosing approach or to be exact the methodology that appropriate for such development. I am still new in design and analysis, so any extra informations are greatly appreciated. Right now, it is the initial phase, planning. So I need to decide which to adapt. I had been read some of the open source projects code, and majority seems...
0
9600
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
10628
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10373
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...
0
9195
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
7651
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
6880
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();...
0
5547
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4331
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
3859
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.