Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
>I have a class that handles updates/adds/deletes for a passed view. Everything works fine, but I have a methodology question. One of the methods (UpdateKeyFields) is used to handle populating key fields and the control field with required data when adding a record. I use a case statement that has specific criteria depending on the view passed. I would like to have the class perform entirely independently and having this conditional method bothers me. It's no big deal to modify it for different views within the application - I just feel it should be done differently. Any ideas? Thanks!
>
>Regards, Renoir
If this is the only location in the class where you have a conditional to address the different views, then Pamela's suggestion is a solid one. On the other hand, an appropriate question is how will that benefit the application in a practical way? The more data-driven the rest of the application, the more that this would fit the pattern. But, otherwise, it may not have a lot of benefit.
If you have multiple methods which behave differently for the different views, then subclassing the class to handle the separate views would simplify code all around. You could then use an abstract factory to determine which subclass to instantiate to handle the specific view.
Or, do nothing...<g>
Jay
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only