Architecture :: Interface, Abstract Or Inheritance?

Oct 7, 2010

I have a table which houses two entities. StaticProgram and DynamicProgram. There is one column in that table called ProgramType which determines if a program is of Type static or Dynamic. Though these two entities are stored in one table (I am guessing because the primitive fields for Static and Dynamic programs are exactly the same) but from a business point of view these are two VERY different entities.

So, I created two Classes StaticProgram and DynamicProgram. However, I donot want to create two seperate Data Access Classes because it is going to be the exact same code replicated twice. I tried creating a "Program" class as base class and inherited StaticProgram and DynamicProgram classes but down casting is not supported so I can't return a "Program" object from the data access class and cast it to "StaticProgram" class.So, what are my options? Can I create an IProgram interface and have StaticProgram and DynamicProgram implement that interface and have my Data Access class return IProgram?

View 1 Replies


Similar Messages:

Web Forms :: Inheritance And Interface/abstract Method To Be Implemented On Muliple Aspx Pages?

Dec 13, 2010

I am working on a asp.net reporting project using crystal reports. I am a little new to working on making the project dynamic or reducing down code.

I have many aspx pages which are using the same logic of collecting input from textboxes and inputing to business logic layer.

I was thinking if someone can suggest me inheritance and interface/abstract method to be implemented on muliple aspx pages?

View 9 Replies

MVC :: Cannot Create An Instance Of The Abstract Class Or Interface?

Dec 12, 2010

Error 1279 Cannot create an instance of the abstract class or interface 'System.Web.Mvc.FileResult'

[Code]....

I am using MVC 2. The same code works in my onather application. I have no idea about this error.

View 2 Replies

Difference Beteween AbstractClass And InterFace And Inheritance?

Feb 17, 2010

Difference beteween AbstractClass and InterFace and Inheritence. And What is the major role of these in OOPS Concepts.

View 1 Replies

Architecture :: What Is The Function Of Abstract Class

Oct 24, 2010

what is the function of abstract class, why design pattern need to build BLL and DAL

anyone give an example for my reference as I am getting strat to build my web-based project

View 3 Replies

Architecture :: Singleton Pattern And Abstract Class?

Aug 19, 2010

I know what Singleton Pattern means and Abstract class means.What I wanted to know was how would this apply to real world.Could anyone give me any good example or simple explanation.Say I have a simple website, why would I use any of the above if any.Why would it simplify my architechture.

View 3 Replies

Architecture :: Use Of Abstract Class Design In Real Time Projects?

Jul 21, 2010

What is the use of abstract class design in real time projects

and how to use abstract clases and interfaces

and inheritense concepts

like big shoping portals or content managment,blogs etc

View 5 Replies

Architecture :: Reason That Multiple Inheritance Not Allowed

Nov 19, 2010

What is the reason that mulitple inheritance is not allowed in .net.

View 2 Replies

Use Abstract Class And Interface Class?

Jan 29, 2010

When to use Abstract class and when to use Interface class.

View 10 Replies

Architecture :: Use A C# Class Or A Interface?

Feb 3, 2011

I have a block of SQL statements that I like to use as a sort of function.

I was thinking that I could make a class and inherit all of the master function, then add the parts that I need for other sections of the program in a sub class.

The problem is, up to this point I've been programming ASP .Net through visual studio, and it's kind of just programming behind controls. I'm not sure where to put the class/function/method/interface, or whatever we call it.

Of course you probably know that visual studio creates a bunch of partial classes when you do an ASP. Net application... so.. to get access to a function like object, across classes.. use an Interface?

View 7 Replies

Architecture :: What's The Advantages / Disadvantages Of Explicit Interface Implementation

Jul 19, 2010

I am searching for the advantages and disadvantages of the explicit interface implementation

View 1 Replies

Architecture :: Creating Each Class Library Project For Interface?

Jan 11, 2010

weather to create each class libaray project for Interface, Service, Model, DTO, Repository ?

View 1 Replies

Architecture :: Handling Asynchronous Server To Server Interface?

Mar 11, 2010

So this interface allows one server to request data from another server. The catch is that all xml for the interface is transmitted entirely over http posts followed by an empty status code 200 response. No data is sent in a response. So if my application wants to requests data, we send an http post with the xml request and receive a blank 200. Then, shortly after our request, we'll receive an http post to a predetermined URL with the xml data which we then send a blank 200. This data will then be stored in a SQL database. This interface cannot be altered.

The reason this is problematic is because our server is handling requests from clients that need that data in the response. If a user requests for data that isn't available in our database, it needs to be requested from the interface and then returned in the response. I'm just not sure how to get this to work out. I've thought about polling the database, but I'm worried about thread pool issues. I've also looked into using ManualResetEvent.WaitOne to halt the processing of the client request and then calling Set when the interface sends the data (as a request). I've read that wait threads are shared, but just don't know if this will scale well. Does anyone have any insight or I'm pretty much stumped on this one...

View 4 Replies

Not Marked Abstract Or Extern?

Jun 30, 2010

[Code]....

Im getting the error message:'User.Id.get' must declare a body because it is not marked abstract or externWhat does this mean? What am I doing wrong?

View 4 Replies

Recommendations For Abstract Class Vs Interfaces?

Dec 21, 2010

From the following URL i got some doubts about the Recommendations for using Abstract class vs interfaces

[URL]

1. If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface. { Is there any example for this t ounderstand throughly ?} If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class. If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members. { Is there any example for this t ounderstand throughly?

View 3 Replies

C# - Cannot Create Instance Of Abstract Class?

Mar 31, 2010

I am trying to compile the following code and i am getting the error:

Cannot create instance of abstract class .

m_objExcel = new Excel.Application();
m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
m_objBook = (Excel._Workbook)(m_objBooks.Add(m_objOpt));
m_objSheets = (Excel.Sheets)m_objBook.Worksheets;
m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(1));
// Create an array for the headers and add it to cells A1:C1.
object[] objHeaders = {"Order ID", "Amount", "Tax"};
m_objRange = m_objSheet.get_Range("A1", "C1");
m_objRange.Value = objHeaders;
m_objFont = m_objRange.Font;
m_objFont.Bold=true;
// Create an array with 3 columns and 100 rows and add it to
// the worksheet starting at cell A2.
object[,] objData = new Object[100,3];
Random rdm = new Random((int)DateTime.Now.Ticks);
double nOrderAmt, nTax;
for(int r=0;r<100;r++)
{
objData[r,0] = "ORD" + r.ToString("0000");
nOrderAmt = rdm.Next(1000);
objData[r,1] = nOrderAmt.ToString("c");
nTax = nOrderAmt*0.07;
objData[r,2] = nTax.ToString("c");
}
m_objRange = m_objSheet.get_Range("A2", m_objOpt);
m_objRange = m_objRange.get_Resize(100,3);
m_objRange.Value = objData;
// Save the Workbook and quit Excel.
m_objBook.SaveAs(m_strSampleFolder + "Book2.xls", m_objOpt, m_objOpt,
m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook.Close(false, m_objOpt, m_objOpt);
m_objExcel.Quit();

View 2 Replies

Use Of Abstract Class In Shopping Portal?

Jul 27, 2010

I just want to know that how can I utilize the concept of Abstract class, virtual class etc. in my shopping cart website. I have read the tutorial out there on internet and I saw some examples too, but those examples are so general that they dosen't fit into real world scenerio like I am searching for a shopping website. Same questions again and again comes to my mind that why to made a class only to give the declaration of methods and property.

View 4 Replies

Cannot Create The Object Of Abstract Class

Apr 22, 2010

We all know that, we cannot create the object of Abstract class.

But why it is so?

I mean, can anyone explain it with real time example?

View 8 Replies

Why Use Reference Of Abstract Class To Create Object

Jul 22, 2010

Why do we use the reference of abstract class (or base class) to create object of it's sub-class. eg: TextWriter is the abstract class for StreamWriter & StreamWriter.

TextWriter writer = new StreamWriter();

why can't we simply use :

StreamWriter writer = new StreamWriter();

View 3 Replies

ADO.NET :: LINQ To SQL Inherited Classes With Abstract Functions?

Aug 16, 2010

I'm building a web app that will keep a events in a database and add the event to a Google calendar on insertion.

I have three types of events, PendingEvents, ApprovedEvents, and DeniedEvents. I'm using single table inheritance through LINQ-to-SQL, with the Event class being abstract and the 3 types inheriting from it

Each type of Event is stored in calendars differently. I would like to use an abstract member function in Event called AddToCalendar.

I'm trying to set this up in a separate class file because I'm using the LINQ-to-SQL designer and I don't want these to be overwritten if I change the LINQ diagram.

However, I get an error from all three inherited classes that "'WebCal.ApprovedEvents' does not implement inherited abstract member 'Edu.Northwestern.WebCal.Event.AddEventToCalendar()' WebCalendarWebApplication1App_CodeWebCalDataSource.designer.cs"

It looks like it won't check my outside file and only looks at the designer.

The non-designer partial class file looks something like this:

public partial class WebCalDataSourceDataContext : System.Data.Linq.DataContext
{

View 2 Replies

Error / Must Declare A Body Because It Is Not Marked Abstract Or Extern? C#/ .NET

Mar 24, 2011

I have a normal web form with code behind, in this code behind I can instantiate a couple of classes I have in the root folder, such as:

public partial class _Default : System.Web.UI.Page

{
Helper helper = new Helper();

protected void Page_Load(object sender, EventArgs e)[code]....

It's working fine but I now want to move my class files (Helper.cs for example) to the app_code folder but when I run the application I get error on

SharePoint sharePoint = new SharePoint();
public string id { get; set; }

must declare a body because it is not marked abstract or extern,

View 2 Replies

C# - Abstract Tree View Node Creation/ Population?

Nov 11, 2010

i have the below code i want to put in a global method set as static so that i can build a couple tree views on my asp.net web app. now i have each building its own tree view using the code below. i was thinking to make a global static method to generate the node structure such as this and then just assign them to the tree view in my pages... or something like this. i dotn care about the details of the actual solution as long as i can have a single method to call like "buildTree()" that will be able to be used to bind the tree view controls to.toughs?

DataTable dtProjects = new DataTable();
DataTable dtRelease = new DataTable();
using (SqlConnection con = Global.GetConnection())

[code]...

View 1 Replies

Best Configuration In CTP 5 For Inheritance ?

Feb 1, 2011

what is best to use in CTP 5 for inheritence. Ive heard of 3 ways of doing it. (This is indirectly addressed to Serenarules )

Table per Hierarchy ?
Table per Type ?
or able per Concrete Type ?

For those who wondering what the hell is that.. refer to http://weblogs.asp.net/manavi/default.aspx which is a nice blog about inheritence and polymorphism in CTP 5.

View 5 Replies

Mvc - ASP ActionFilters And Inheritance

Jul 16, 2010

All my controllers inherit from a BaseController that has an ActionFilter attribute:

[AnalyticsData]
public class BaseController : Controller {}
public class AccountController : BaseController {}
Some of my Actions in my controllers reuse the AnalyticsData ActionFilter:
public class AccountController : BaseController
{
[AnalyticsData(Page="AccountProfile")]
public ActionResult Profile()
{
// return View
}
}

I notice that the AnalyticsData ActionFilter only runs once. This is a good thing and I only want it to run once, but I'm wondering how that happens. If I set my breakpoint inside the OnActionExecuting:

public class AnalyticsAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// break point set here
}
}

only gets hit once when AccountController serves it Profile view. How do ActionFilters and/or Attributes work that [AnalyticsData(Page="AccountProfile")] on the Action overrides/replaces [AnalyticsData] on BaseController?

View 1 Replies

Creating An Abstract Class That Will Define All Database Manipulation Methods To Implement

Mar 3, 2010

I am developing a couple of small ASP.NET application and would like to know what pattern. approach do you use in your projects.

My projects involve databases, using Data access and Business logic layers.

The data-access approach that I was using so far is the following(I read in some book and liked it):

For DAL layer:

Creating an abstract class that will define all database manipulation methods to implement.
The abstract class will contain a static "Instance" property, that will load (if instance == null) an instance (Activator.CreateInstance) of the needed type (a class that implements it).

Creating a classes that implement this abstract class, the implementation will be according to the databases (SQL, mySQL and etc) in use.

With this I can create different implementation according to database in use.

For BLL layer:

A class that encapsulates all all retrieved fields , and static methods that will call the DAL classes.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved