Help: Which design method should I use for this particular case?
-
I am going to develop a new class. But I do not have the full list of functionalities to be included in this class right now. But I would like to add new features at different times in the future. i.e I want to add new features to an existing class from time to time in the future as the new requirement arise. How should I start and which design pattern fits my requirement. I do not have prior experience in using or applying patterns. I am starting out. If this is not the right place please guide me which codeguru forum I should resort to, to have more knowledge on applying design patterns. Thanks, ManojE
-
I am going to develop a new class. But I do not have the full list of functionalities to be included in this class right now. But I would like to add new features at different times in the future. i.e I want to add new features to an existing class from time to time in the future as the new requirement arise. How should I start and which design pattern fits my requirement. I do not have prior experience in using or applying patterns. I am starting out. If this is not the right place please guide me which codeguru forum I should resort to, to have more knowledge on applying design patterns. Thanks, ManojE
xyzsnl wrote:
But I do not have the full list of functionalities to be included in this class right now. But I would like to add new features at different times in the future
Classes are small constructs, and ideally they'd only have a single responsibility. Implementing a lot of functionality in a single class, and modifying that, would be rather inefficient and error-prone. There's a multitude of ways to extend classes, the most obvious being inheritance. In essence, you create a new class and "inherit" all the things from some other class you wrote. There's also the option of creating abstract classes; that would only contain a definition, similar to an interface. You could provide different implementations as required.
xyzsnl wrote:
How should I start and which design pattern fits my requirement.
Most design-patterns consist out of more than one single class. I liked the Strategy[^]-pattern as an introduction to design patterns. As you learn more, you'll recognize them in the .NET Framework itself. Happy Programming :)
My last article[^] - It's been a while :suss:
-
I am going to develop a new class. But I do not have the full list of functionalities to be included in this class right now. But I would like to add new features at different times in the future. i.e I want to add new features to an existing class from time to time in the future as the new requirement arise. How should I start and which design pattern fits my requirement. I do not have prior experience in using or applying patterns. I am starting out. If this is not the right place please guide me which codeguru forum I should resort to, to have more knowledge on applying design patterns. Thanks, ManojE
Classes are extensible by nature. So you can extended them as required. Apply patterns to your class as required. Don't apply patterns that are not required, otherwise in the future, you will assume that the class behaves in a way it doesn't.
Architecture is extensible, code is minimal.