Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm thinking <a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="nofollow">Startegy</a> and <a href="http://en.wikipedia.org/wiki/Factory_method_pattern" rel="nofollow">Factory</a> design patterns.</p> <p>You could do something in the lines of:</p> <p>In your UI:</p> <pre><code>var chartStartegyFactory = new ChartStrategyFactory(); var chartStategy = chartStartegyFactory.Create(ddlApplication.SelectedItem.Text, ddlTests.SelectedItem.Text); var chart = chartStategy.CreateChart(); lblTotalTestsRapp.Text = chart.ChartData; SpecificTestsRapp.ChartTitle = chart.ChartTitle; TotalTestsWeb6.Visible = chart.TotalTestsWeb6Visible; // continue assigning properties in your UI </code></pre> <p>In your business layer:</p> <pre><code> public class ChartStrategyFactory { public IChartStrategy Create(string application, string test) { if (application == "Rapp" &amp;&amp; test == "Total Test Runs") return new RappTotalTestsRunChartStrategy(); // add strategies for other charts throw new NotSupportedException(); } } public interface IChartStrategy { Chart CreateChart(); } public class Chart { public string ChartTitle { get; set; } public string ChartData { get; set; } public bool TotalTestsWeb6Visible { get; set; } // create all properties you need } public class RappTotalTestsRunChartStrategy : IChartStrategy { public Chart CreateChart(){ Chart chart = new Chart(); chart.ChartData = GetDataFromDatabase(); chart.ChartTitle = "Your Chart Title"; chart.TotalTestsWeb6Visible = false; // continue assigning properties return chart; } } </code></pre> <p>Basically your Chart creation code will be encapsulated in each Startegy and you will gain extensibility (it suffices to modify your ChartStrategyFactory when a new chart is developed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload