1

I'd like suggestions for the design of a CRUD business app using Silverlight 4, the Business Application Template, WCF RIA Services and the Entity Framework 4. The app tracks lab test results performed on material samples. It replaces a (difficult to maintain) existing web application. Lab tests results are stored in two "SampleData" tables made up of hundreds of fields. The tables have a one to one relationship. I combined the two tables into one using Entity Framework's Table Per Type Inheritance which I'm very happy with. Note: I've decided not to change the database design to avoid destroying the existing application, but it was considered.

My dilemma is how to break up this huge table. Each record represents a material sample that is tested. The logical grouping of fields is by lab test. I envision my UI having multiple tabs or separate pages - one for each test. The problem at this point is that I'm sucking in ALL the fields yet only displaying a few in a paged DataGrid and there is a noticeable delay. Instead of one giant entity it might be nice to have several "Lab Test" entities (each representing a type of test) that are sub-sets of my one giant TPT Inheritance table. How would I do this? The base SampleData table/entity contains header fields plus several child test results fields. The second derived table/entity contains more test result fields linked to the base by SampleID. If split up I'd need to maintain the header info with each Lab Test entity.

I'm willing to stick with one giant table/entity (despite a slight performance penalty). Still, I'm wondering the best way to create my UI with this one entity. Can a DataForm be tabbed? If I make a dashboard with links to lab tests how do I keep header info in sync with each test page?

I know this is a broad question. I'm hoping to get suggestions on a good design path that will allow me to grow the app as new lab tests are added (making an even bigger entity). I'd hope to find a path that simplifies maintenance and takes advantage of the RAD experience Microsoft is promoting.

Thanks in advance!

Community
  • 1
  • 1
DeveloperDan
  • 4,626
  • 9
  • 40
  • 65
  • If you don't mind me asking, why do you feel the web app is hard to maintain? I'm in the process of switching from Silverlight/RIA Services to ASP.NET MVC because I have found the opposite: SL/RIA is difficult to maintain and slow development progress. I find it all very heavyweight and inflexible. – Matt Greer Dec 17 '10 at 00:10
  • Half the app is in Asp 1.1 using ancient treeview and tab controls. One of the tabs has a frame which contains an entire Asp 2.0 app. Serious refactoring is needed (and I've started). Multi-dimensional arrays contain database field names and corresponding textBox objects identified by magic index numbers. Database calls are mostly loops to fill arrays or do CRUD. Abandoned code litters the app. Variables are 3 or 4 letter acronyms for who knows what. Frequently the app won't compile and hours are lost. The original developer left the company and I, the new guy, have to deal with the quagmire. – DeveloperDan Dec 17 '10 at 13:25

2 Answers2

0

I scanned the post discussing the database design and must say that based on what you said and the fact that you've already got users asking for more tests (repeating values) that I wish you'd reconsider the db redesign. You can create a flat view to simulate the existing flat samples-data table and use that to minimize breakage in the existing application.

But you've already made that decision, so how about reversing the situation? Instead of fixing the database, add code to the domain service that transforms the data from it's flat layout, leaving out all the null values.

One idea is to write a view that un-flattens the data and leaving out the null no-test situations. The query will raise eyebrows (I'll probably get flamed for this) because it looks nasty but in reality the DBMS does a fine job optimizing and performing the query (in Oracle anyway). I've had great results making a view something like::

create view programmer_exp_unflat as ( select programmer_id, 'C#', csharp_yrs from programmer_exp_flat where csharp_yrs is not null union select programmer_id, 'Java', java_yrs from programmer_exp_flat where java_yrs is not null union select programmer_id, 'Cobol', cobol_yrs from programmer_exp_flat where cobol_yrs is not null . repeat xx times) from dual

It's backwards and ugly no matter how you look at it but it reduces your result set to a bare minimum and no need to break things into categories. New test values require modification of the view, and depending on UI flexibility and business rules, might not require any changes.

It makes coding at the UI more difficult, as it would have been with the right database design in the first place, but your query result is reduced to only the tests that had been completed. If your users are flexible the UI could be designed to show the test results as a list making display a piece of cake. Your current design pretty much forces you to modify the UI and database with each and every new test.

These are the type challenges that make being a developer so much fun -- and why all the marketing gimmick sample CRUD applications that can be built in five minutes are worthless in the real world.

Rich Bianco
  • 4,141
  • 3
  • 29
  • 48
  • I like your un-flattening view. Unfortunately I can't neatly group the columns into categories such as YearsExperience. Instead I my columns track disparate measurements such as temperature, weight, speed, thickness etc. Thanks reminding me that being a developer is so much fun. Sometimes I forget that. – DeveloperDan Dec 17 '10 at 14:56
0

I'm answering (and accepting) my own question to increase my stack overflow accept rate, but my "answer" is that I have found no answer yet. Because I've had to move on with the project I continue to use one giant entity. I've also moved away from Silverlight and turned the project into a WPF app due to various struggles with Silverlight such as inherent asynchronous data access.

DeveloperDan
  • 4,626
  • 9
  • 40
  • 65