Click here to Skip to main content
15,887,596 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: class XXX and class XXXImpl Pin
Mark Churchill9-Jun-08 18:20
Mark Churchill9-Jun-08 18:20 
QuestionAdvice on Architecture for customized application Pin
ruben ruvalcaba20-May-08 4:20
ruben ruvalcaba20-May-08 4:20 
AnswerRe: Advice on Architecture for customized application Pin
Mycroft Holmes23-May-08 1:13
professionalMycroft Holmes23-May-08 1:13 
GeneralRe: Advice on Architecture for customized application Pin
ruben ruvalcaba23-May-08 4:47
ruben ruvalcaba23-May-08 4:47 
AnswerRe: Advice on Architecture for customized application Pin
Scott Dorman25-May-08 2:19
professionalScott Dorman25-May-08 2:19 
GeneralRe: Advice on Architecture for customized application Pin
ruben ruvalcaba26-May-08 4:46
ruben ruvalcaba26-May-08 4:46 
GeneralRe: Advice on Architecture for customized application Pin
Scott Dorman26-May-08 5:09
professionalScott Dorman26-May-08 5:09 
Question'Dynamic' String Formatting Pin
HoltDan18-May-08 15:07
HoltDan18-May-08 15:07 
My users need to be able to specify their own formatting preferences for string output.

So, either in Settings or the database or wherever, they specify a format string: "%lastName% can be reaced at %mainPhone% or %email%" to control the output of this class:

class Person
{
    string nameFirst;
    string nameLast;
    string eMail;
    List<Phone> phones;
}


(which is strictly by example - the real object network will be much larger/complicated)(and tokenizing the format string is no problem for me)

I'm wondering how to best produce the final string at runtime in a reasonably efficient manor. It's doubtful there will be more than a few hundred of these items at a time (less than a dozen most likely) and this string will be produced for tooltips, columns in grids, reports, etc. Still - while I don't have to worry about this being executed 1,000 a second - I'd like for it not to be too much of a pig. Maintainability is more of a concern.

It seems to me this is a good use for codeDOM and generating a dynamic method. When the app is loaded, it reads the configuration string and generates a method that looks

string DisplayAs()
{
   // i.e. based on the configuration string originally specified as "%lastName% can be reaced at %mainPhone% or %email%"
   string fmt = "{0} can be reached at {1} or {2}"; 

   string[] args = { nameLast, SomeMethodThatKnowsHowToDetermin_MAIN_PhoneFromList(), eMail };

   return string.Format ( fmt, args );
}

I've never used the codeDOM but I think I can manage something like this. But is this overkill or maybe there's a better way?

I could take a brute force approach and loop through whatever format string the user supplies doing string substitutions based on my list of 'keywords' (i.e. %mainPhone%) but there could easily be a dozen or so of those keywords. That seems painfully inefficient to me - but maybe not to the extent I should worry about it.

Thanks,
Dan Holt
AnswerRe: 'Dynamic' String Formatting Pin
led mike19-May-08 4:58
led mike19-May-08 4:58 
GeneralRe: 'Dynamic' String Formatting Pin
HoltDan19-May-08 5:50
HoltDan19-May-08 5:50 
GeneralRe: 'Dynamic' String Formatting Pin
led mike19-May-08 6:08
led mike19-May-08 6:08 
GeneralRe: 'Dynamic' String Formatting Pin
Roger Alsing20-May-08 4:06
Roger Alsing20-May-08 4:06 
GeneralRe: 'Dynamic' String Formatting Pin
Scott Dorman25-May-08 2:31
professionalScott Dorman25-May-08 2:31 
QuestionHelp with a inheritance best practices question Pin
turnergg18-May-08 8:20
turnergg18-May-08 8:20 
AnswerRe: Help with a inheritance best practices question Pin
led mike19-May-08 4:51
led mike19-May-08 4:51 
AnswerRe: Help with a inheritance best practices question Pin
Tim Yen24-May-08 19:40
Tim Yen24-May-08 19:40 
QuestionDecalring global variable in VBA editor. Pin
raja baireddy17-May-08 2:31
raja baireddy17-May-08 2:31 
AnswerRe: Decalring global variable in VBA editor. Pin
Pete O'Hanlon17-May-08 8:46
mvePete O'Hanlon17-May-08 8:46 
GeneralRe: Decalring global variable in VBA editor. Pin
led mike19-May-08 4:43
led mike19-May-08 4:43 
Questiontracking sales of electronic pump machines Pin
mickeyen17-May-08 2:16
mickeyen17-May-08 2:16 
AnswerRe: tracking sales of electronic pump machines Pin
led mike19-May-08 5:05
led mike19-May-08 5:05 
GeneralRe: tracking sales of electronic pump machines Pin
mickeyen25-May-08 15:33
mickeyen25-May-08 15:33 
GeneralRe: tracking sales of electronic pump machines Pin
Mark Churchill10-Jun-08 21:07
Mark Churchill10-Jun-08 21:07 
GeneralRe: tracking sales of electronic pump machines Pin
mickeyen15-Jun-08 14:36
mickeyen15-Jun-08 14:36 
QuestionCommand Pattern Implementation [modified] Pin
Tristan Rhodes16-May-08 5:29
Tristan Rhodes16-May-08 5:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.