design - Suggested architecture for associating code to db rows -


I have a situation where there is a bunch of rows in my database. For example, suppose we have a ReportRendererType table is.

  • Line graphs
  • Bar graphs
  • Grid
  • P> etc.

    For example, I want to see the database specifically for viewing specific stores. Frank liked the profit report displayed in the bar graph. It would be cute if I can add code with DB entry. In other words, it would be nice if the LineGraphRenderer class knew that it was affiliated with line 1 in ReportRenderType table. This is a trivial example of why this would be useful, that you can populate a dropdown list of ReportRenderType options, and then select a value and a manager class can easily find that the value selected from the dropdown list How to be displayed. The question is - how do you relate between DB and that part of the code?

    There are a lot of options:

    A When you create LineGraphRenderer class, you may have a Property ReportRendererType, which returned the primary key of the corresponding row.

    B You can have a LineGraphRenderer return an enumeration that contains the value of the primary key (C # allows you to set the hash code value explicitly), it gives stable typing, and One place for all DB entries.

    c. You can get a ReportRendererType property on LineGraphRenderer, which brings back the primary key but has retrieved the value of the row associated with a setting file. This will facilitate the formation of institutions, especially if someone else has primary primary value. For example, in Company A there may be stored in line 1 in line 1, but in Company B, it can be stored in line 2 in line 2.

    Unfortunately, all these methods also have drawbacks. I'm thinking how this problem is being handled by others, and if I find some good ways of doing things I remember.

    I recommend that you not associate code with database rows! This is exactly the opposite to separating the concerns.

    Honestly, I have ever heard that it is not the most pleasant idea; But it is very close.


    Comments

    Popular posts from this blog

    c++ - Linux and clipboard -

    What is expire header and how to achive them in ASP.NET and PHP? -

    sql server - How can I determine which of my SQL 2005 statistics are unused? -