.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Class Design Question

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :ASP.Net


I have a question about class design. Currently I am working with following tables:

| Forms
| FormID (PK)
| CommitmentID (FK)
| ...

| Commitments
| CommitmentID (PK)
| CommitDesc
| ...

| Pricings
| PricingID (PK)
| Desc
| CommitmentID (FK)
| ...

| PricingTiers
| TierID (PK)
| PricingID (FK)
| Desc
| ...

Forms <-one to one-> Commitment
Commitment <-one to many-> Pricing
Pricing <-one to many-> PricingTiers

When designing the classes what would be considered a best practice ... for instance at the moment I have 4 classes "Form", "Commitment", "Pricing", and "PricingTier" respectively.

Form class has a public property Commitment which represents an instance of the Commitment class.

Commitment class has a public property List<Pricing> which represents the one to many (Commitment - Pricing) relat

View Complete Post

More Related Resource Links

Design Question - Child Class Reference


There has to be a better way to design the following:

public class Member {
  public int stateID {get; set;}

  public State state {
    get {
      if (this.stateID > 0) 
        state = State.GetByID(this.stateID);

public class State {
  public string name {get; set; }

  public static State GetByID(int id) {
    //populates state from db

Now if I loop through a list of members and need to display the state name for each member and I call "myMember.State.name" - I'll get the name of the state but it costs me an extra query everytime I call that - even though some of the states may be the same.

Is there a way somehow keep some sort of cache of state name from the db for access?


Question on WorkflowApplication class design ( Func Properties)





I found out that the Workflow Application class offers Func<T> properties to inject code for example when a error occurs.

whats the reason behind the Design Decission of giving the WorkFlow Foundation class Func<T> properties instead of event?


For Example


 Func<WorkflowApplicationUnhandledExceptionEventArgs, UnhandledExceptionAction> OnUnhandledException { get

; set

; }





 Action<WorkflowApplicationCompletedEventArgs> Completed { get

; set

; }


Is it just to prevent the multiple receipients ?

Or is it related to memory mangement due to fix pins caused by eventhandlers ? To be honest i must confess that i'm not sure wether Func<T> will created a fix pin in memory :-(

I'm not sure about if this is good or not, but it would be very nice to get knowledge of the reason why this class is event

database interface design question


For handy database interface, is it good to use SqldataSources exclusively intead of EntLib functions?

Thanks for any feedback.

I need a workflow triggered by a workflow...how do I design this? Beginner question

I've added the Approval workflow to a forms library and it generates the necessary tasks and emails for 2 levels (serial) of Approval on the form. When the form has been approved the 2nd time, I want it to trigger another workflow that notifies a 3rd person of the existence of the form and assigns her a separate non-approval task. I'm creating it in SharePoint Designer, and I can do most of it, but I'm not sure what field I'm looking for, at the beginning in order to start the workflow. Currently, there is no column for Approval Status in the form library, only a column that shows the status of the workflow (In Progress or Approved).  I tried If Workflow Status equals Approved then email.... but that didn't work. Any help is greatly appreciated.  I'm looking for the data source field and the list item field and value, I guess.  

WCF and Entity Framework Design question

Should we be using Entity Framework entities as data contracts across the WCF Layer? If yes when why have the POCO support and code only been added to the Entity Framework? I was assuming it was with the purpose to remove the dependancy that the client will have on the database if the client depends on the Entities. If No, then does that mean we need to create Business Objects for each entity that exists in the entity framework model? Please advise. Thanks.Nilotpal

Pipeline Data Cube Design Question



The Analysis team wants to analyze sales pipeline data. Our CRM system(Source system) send the Data Warehouse team transaction as the Product moves through the different stages.


To mention a few: Creation, CallMade,LeadEngaged,CreditCheck,PapersReceived,Closed.There are more than 100 tracking statuses like mentioned above.


Sample transactions fact table:


Question on a class that is reused


I have a generic class that just has the following:

    public class GenericMap

        private int _Number_1 = 0,
                    _Number_2 = 0,
                    _Number_3 = 0,
                    _Number_4 = 0,
                    _Number_5 = 0,
                    _Number_6 = 0,
                    _Number_7 = 0,
                    _Number_8 = 0;
        private string _String_1 = string.Empty,

Question of replacement of if..else conditions with design pattern



I am working on an application which contains code in lot of places where certain objects are created based on certain condition. The code is something like the following:

if(affectedObject == "Customer")
     Customer c  = new Customer();
else if(affectedObject == "Salesman")
     SalesMan s = new SalesMan();

// or 

     case "Manager":
          // Do some processing.
     case "Employee":
          // Do another processing.


I have gone through design patterns once but I am not able to figure out how I can use a pattern to replace my code.

Can any one please help me with this? Any practical code sample would be of great help (code without refactoring and refactored code) so that I can understand it better.

Thanks in advance.

CLASS question


Hi guys!


I have a class like this:


namespace Core.Utils
    public class getText

        public string getText(string ext){

            string result = "The String: " + ext
            return result;



Normally, I use it like this:


var xx = new getText();

var yy = xx.getText("AAA");



I want to know how to be able to use it like this:


var yy = new getText("AAA");


It's that possible?

Thanks in advance!


Worker & Location Database design question


Hello to forums :)


I have a simple question on design.

A company has several 'Worklocations'. Each location employs several workers. Every worker can be associated with multiple locations.

So, I have decided to create below tables. please letme know if there is a better way to design it

worker table
wid (primary)

location table
lid (primary)

workerlocations (WID+LID => primary key)

Is this sounds right for you guys? let me know

Binding Question How does one set datacontext to same class in XAML?


I have a usercontrol with one button in it.  I want to set the text via a property getter setter using the INotifyPropertyChanged interface in code behind.  I can get it to work if I set the DATACONTEXT in code behind in the CTOR like this : DataContext = this;  Everything works perfect. 

But here's the problem.  If I try to do this in xaml by defining an XMLNS which points to the folder this usercontrol is in, and then attempt to reference it as a resouce like this <local:XXXXXX  <-------The XXXX which is the class name of this control can't be found?  Is that wierd?  Can't a resource be itself?  So that I can set the Datacontext in the XAML instead of code behind?  I've tried to bind to relative source self, but cannot set the property (Event when I attempted to created a dependency property).....  Just wondering how one sets up Datacontext to the same class? 


Design question in Report Manager?

When you view/launch a report by clicking on it in Report Manager you get a "double arrow" on the right side of the window with the help text "Full screen". If you push that button the top area with links to for example "Site settings" disapears. Is there any way to make that the default setting when you view a report?

I cant find anything about this in my books, can anyone help me?


Help with Class Design


This might be the wrong forum, any help is appreciated. So I have an application that allows admins to add types such as document types and training types that are in seperate tables with a foreign key in a transaction table.

When structuring my class I decided to go with an abstract-like pattern (without the factory methods though). So I have a Type abstract class that defines my Save, Delete, and GetList methods. I have a training type class that inherits this class. The thing is all types have 3 main properties - defined in the abstract base - but have different source tables and thus different store procedures in my DbCommand object. So basically I repeat setting up the same parameters on all the derived classes. I would like to implement the common stuff in the base but I am getting thrown off by the difference in data sources.

Thanks in advance!

Multiple users system design question.



I am designing a web application that will allow users to accept jobs.  Once accepted, the job is locked until completed or released my an admin. 

I have researched this pretty heavily, everything seems to suggest this.  While I think this might be part of the solution, I am still wondering how to reflect the change on the screen. 

The solution we have come up with is to do polling with ajax, but the case we come back to is even if we check ever second...there can be ( and this is very likely ) that two or more users will click the same job at the same time.

Maybe this is as easy as this:

if( job.isLocked() ) {

    // Notify the user, and refresh grid.
    WarningLabel.Text = "Job is taken!!!!";


Our users use IE7 if this matters.  If anybody can give me a confirmation if this is the 'right' way to go about this, or propose other options I would greatly appreicate it.

How to design a class for product searching


Hello, I'm refactoring an old website that has product search code littered throught the codebehind. I'm trying to encapsulate the search logic into its own class so I've created a Product class with a Search() method. I would like some suggestions about OO best practices so that the class is reusable and maintainable. The questions I have are:

- Should I make the search() method an instance method or make it static? For now the class is just really there to encapsulate my search logic 

- If I make it an instance method should it return a list of products or should it populate a member property that I can access like p.Search(); var x = p.ProductList;

- The search method requires upward of 7 parameters of different types, what's the best way to provide them?
    - pass them all i.e. p.Search (param1, param2, ..., param7)
    - create a SearchParams structure in the class, populate it and pass that i.e. p.Search(searchParams)
    - Instantiate a Product object and set properties on it that are used by the Search method i.e.  p.ID = 123; etc.... p.Search();

I've used variations of the above before but would like to know what's the best way.



Data Class Best Practices Question


Hi all.

I have a class called employee.  I have several private fields (i.e. mHiredDate, mSickDays, mVacationDays, etc.).  I instantiate employee objects thru out my website application.  When I make a change to the private fields using the public property set method, is it a better practice to make the changes thru out the session and save the values back to the database near the end of the session or make the set make the change to the database everytime it is called?  Does the same go for get ?  Do I have my get goto the database and grab the value everytime I need it ?

I hope my question is clear enough. 

Thanks Smile


WCF - Basic Design Question Regarding No. Of Services vs No. of Tables



Let's say you have N tables, and you want to write CRUD as per table not in an OO fashio. 

How many WCF services are required?

is it near 5 * N (C,U,D, R and List with different criteria)? 

Or would you have 1 service that takes care of all the CRUD?

What would be the interface (parameters) passed to such a service.

The number does not really matter, in fact the only thing I care about is the architecture.

If you are not able to provide detailed answers, please point me to where I can learn more about this.

Thank you.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend